1
0
mirror of https://github.com/alecthomas/chroma.git synced 2025-03-29 21:56:56 +02:00

Fix incorrect javascript comment highlight (#104)

This commit is contained in:
Sergey Yagodkin 2018-02-08 01:56:56 +03:00 committed by Alec Thomas
parent 35126f9a94
commit a35b8fe9bd
3 changed files with 32 additions and 0 deletions

View File

@ -65,6 +65,7 @@ var Javascript = Register(MustNewLexer(
Filenames: []string{"*.js", "*.jsm"},
MimeTypes: []string{"application/javascript", "application/x-javascript", "text/x-javascript", "text/javascript"},
DotAll: true,
EnsureNL: true,
},
JavascriptRules,
))

2
lexers/testdata/javascript.actual vendored Normal file
View File

@ -0,0 +1,2 @@
sum = parseInt(num1) + parseInt(num2) // "+" means "add"
alert("Sum = " + sum) // "+" means combine into a string

29
lexers/testdata/javascript.expected vendored Normal file
View File

@ -0,0 +1,29 @@
[
{"type":"NameOther","value":"sum"},
{"type":"Text","value":" "},
{"type":"Operator","value":"="},
{"type":"Text","value":" "},
{"type":"NameBuiltin","value":"parseInt"},
{"type":"Punctuation","value":"("},
{"type":"NameOther","value":"num1"},
{"type":"Punctuation","value":")"},
{"type":"Text","value":" "},
{"type":"Operator","value":"+"},
{"type":"Text","value":" "},
{"type":"NameBuiltin","value":"parseInt"},
{"type":"Punctuation","value":"("},
{"type":"NameOther","value":"num2"},
{"type":"Punctuation","value":")"},
{"type":"Text","value":" "},
{"type":"CommentSingle","value":"// \"+\" means \"add\"\n"},
{"type":"NameOther","value":"alert"},
{"type":"Punctuation","value":"("},
{"type":"LiteralStringDouble","value":"\"Sum = \""},
{"type":"Text","value":" "},
{"type":"Operator","value":"+"},
{"type":"Text","value":" "},
{"type":"NameOther","value":"sum"},
{"type":"Punctuation","value":")"},
{"type":"Text","value":" "},
{"type":"CommentSingle","value":"// \"+\" means combine into a string\n"}
]