1
0
mirror of https://github.com/alecthomas/chroma.git synced 2025-03-17 20:58:08 +02:00

Support lone '$' in Go templates.

This commit is contained in:
Alec Thomas 2021-02-08 12:24:52 +11:00
parent c49d52b472
commit e6d871d955
3 changed files with 10 additions and 2 deletions

View File

@ -87,7 +87,7 @@ func goTemplateRules() Rules {
{`(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},
{`[$]?[^\W\d]\w*`, NameOther, nil},
{`[$]?\.(?:[^\W\d]\w*)?`, NameAttribute, nil},
{`\$|[$]?\.(?:[^\W\d]\w*)?`, NameAttribute, nil},
{`"(\\\\|\\"|[^"])*"`, LiteralString, nil},
{`-?\d+i`, LiteralNumber, nil},
{`-?\d+\.\d*([Ee][-+]\d+)?i`, LiteralNumber, nil},

View File

@ -7,4 +7,6 @@
{{ range $idx, $value := $variable }}
Hello {{ $idx }}
{{ end }}
{{ end }}
{{ $ }}

View File

@ -46,5 +46,11 @@
{"type":"TextWhitespace","value":" "},
{"type":"Keyword","value":"end"},
{"type":"TextWhitespace","value":" "},
{"type":"CommentPreproc","value":"}}"},
{"type":"Other","value":"\n\n"},
{"type":"CommentPreproc","value":"{{"},
{"type":"TextWhitespace","value":" "},
{"type":"NameAttribute","value":"$"},
{"type":"TextWhitespace","value":" "},
{"type":"CommentPreproc","value":"}}"}
]