diff --git a/lexers/g/go.go b/lexers/g/go.go index ef400b7..8eced07 100644 --- a/lexers/g/go.go +++ b/lexers/g/go.go @@ -80,7 +80,7 @@ var goTemplateRules = Rules{ {`\s+`, Whitespace, nil}, {`\(`, Operator, Push("subexpression")}, {`(range|if|else|while|with|template|end|true|false|nil|and|call|html|index|js|len|not|or|print|printf|println|urlquery|eq|ne|lt|le|gt|ge)\b`, Keyword, nil}, - {`\||:?=`, Operator, nil}, + {`\||:?=|,`, Operator, nil}, {`[$]?[^\W\d]\w*`, NameOther, nil}, {`[$]?\.(?:[^\W\d]\w*)?`, NameAttribute, nil}, {`"(\\\\|\\"|[^"])*"`, LiteralString, nil}, diff --git a/lexers/testdata/go-text-template.actual b/lexers/testdata/go-text-template.actual index 7761c3d..a014cc1 100644 --- a/lexers/testdata/go-text-template.actual +++ b/lexers/testdata/go-text-template.actual @@ -3,4 +3,8 @@ */}} {{ $myVar := 2 }} -{{ $myVar = 4 }} \ No newline at end of file +{{ $myVar = 4 }} + +{{ range $idx, $value := $variable }} +Hello {{ $idx }} +{{ end }} \ No newline at end of file diff --git a/lexers/testdata/go-text-template.expected b/lexers/testdata/go-text-template.expected index f774669..651c727 100644 --- a/lexers/testdata/go-text-template.expected +++ b/lexers/testdata/go-text-template.expected @@ -19,5 +19,32 @@ {"type":"TextWhitespace","value":" "}, {"type":"NameOther","value":"4"}, {"type":"TextWhitespace","value":" "}, + {"type":"CommentPreproc","value":"}}"}, + {"type":"Other","value":"\n\n"}, + {"type":"CommentPreproc","value":"{{"}, + {"type":"TextWhitespace","value":" "}, + {"type":"Keyword","value":"range"}, + {"type":"TextWhitespace","value":" "}, + {"type":"NameOther","value":"$idx"}, + {"type":"Operator","value":","}, + {"type":"TextWhitespace","value":" "}, + {"type":"NameOther","value":"$value"}, + {"type":"TextWhitespace","value":" "}, + {"type":"Operator","value":":="}, + {"type":"TextWhitespace","value":" "}, + {"type":"NameOther","value":"$variable"}, + {"type":"TextWhitespace","value":" "}, + {"type":"CommentPreproc","value":"}}"}, + {"type":"Other","value":"\nHello "}, + {"type":"CommentPreproc","value":"{{"}, + {"type":"TextWhitespace","value":" "}, + {"type":"NameOther","value":"$idx"}, + {"type":"TextWhitespace","value":" "}, + {"type":"CommentPreproc","value":"}}"}, + {"type":"Other","value":"\n"}, + {"type":"CommentPreproc","value":"{{"}, + {"type":"TextWhitespace","value":" "}, + {"type":"Keyword","value":"end"}, + {"type":"TextWhitespace","value":" "}, {"type":"CommentPreproc","value":"}}"} ]