@@ -1563,6 +1563,39 @@ describe "Javascript grammar", ->
1563
1563
expect (tokens[7 ]).toEqual value : ' , p2 ' , scopes : [' source.js' , ' meta.function.js' , ' meta.parameters.js' , ' comment.block.js' ]
1564
1564
expect (tokens[8 ]).toEqual value : ' */' , scopes : [' source.js' , ' meta.function.js' , ' meta.parameters.js' , ' comment.block.js' , ' punctuation.definition.comment.js' ]
1565
1565
1566
+ it " tokenizes HTML-style comments correctly" , ->
1567
+ {tokens } = grammar .tokenizeLine ' <!-- comment'
1568
+ expect (tokens[0 ]).toEqual value : ' <!--' , scopes : [' source.js' , ' comment.line.html.js' , ' punctuation.definition.comment.html.js' ]
1569
+ expect (tokens[1 ]).toEqual value : ' comment' , scopes : [' source.js' , ' comment.line.html.js' ]
1570
+
1571
+ {tokens } = grammar .tokenizeLine ' --> comment'
1572
+ expect (tokens[0 ]).toEqual value : ' -->' , scopes : [' source.js' , ' comment.line.html.js' , ' punctuation.definition.comment.html.js' ]
1573
+ expect (tokens[1 ]).toEqual value : ' comment' , scopes : [' source.js' , ' comment.line.html.js' ]
1574
+
1575
+ it " stops comments when a </script> tag is encountered" , ->
1576
+ # HTML doesn't count comments if they're followed by a </script> tag. Unfortunately we have
1577
+ # no idea if we're embedded or not, so we err on the side of caution and always assume that we are :/
1578
+
1579
+ {tokens } = grammar .tokenizeLine ' /* </script>'
1580
+ expect (tokens[0 ]).toEqual value : ' /*' , scopes : [' source.js' , ' comment.block.js' , ' punctuation.definition.comment.js' ]
1581
+ expect (tokens[1 ]).not .toEqual value : ' </script>' , scopes : [' source.js' , ' comment.block.js' ]
1582
+
1583
+ {tokens } = grammar .tokenizeLine ' /** </script>'
1584
+ expect (tokens[0 ]).toEqual value : ' /**' , scopes : [' source.js' , ' comment.block.documentation.js' , ' punctuation.definition.comment.js' ]
1585
+ expect (tokens[1 ]).not .toEqual value : ' </script>' , scopes : [' source.js' , ' comment.block.documentation.js' ]
1586
+
1587
+ {tokens } = grammar .tokenizeLine ' // </script>'
1588
+ expect (tokens[0 ]).toEqual value : ' //' , scopes : [' source.js' , ' comment.line.double-slash.js' , ' punctuation.definition.comment.js' ]
1589
+ expect (tokens[1 ]).not .toEqual value : ' </script>' , scopes : [' source.js' , ' comment.line.double-slash.js' ]
1590
+
1591
+ {tokens } = grammar .tokenizeLine ' <!-- </script>'
1592
+ expect (tokens[0 ]).toEqual value : ' <!--' , scopes : [' source.js' , ' comment.line.html.js' , ' punctuation.definition.comment.html.js' ]
1593
+ expect (tokens[1 ]).not .toEqual value : ' </script>' , scopes : [' source.js' , ' comment.line.html.js' ]
1594
+
1595
+ {tokens } = grammar .tokenizeLine ' --> </script>'
1596
+ expect (tokens[0 ]).toEqual value : ' -->' , scopes : [' source.js' , ' comment.line.html.js' , ' punctuation.definition.comment.html.js' ]
1597
+ expect (tokens[1 ]).not .toEqual value : ' </script>' , scopes : [' source.js' , ' comment.line.html.js' ]
1598
+
1566
1599
describe " console" , ->
1567
1600
it " tokenizes the console keyword" , ->
1568
1601
{tokens } = grammar .tokenizeLine (' console;' )
0 commit comments