diff options
Diffstat (limited to 'pygments/lexers/javascript.py')
-rw-r--r-- | pygments/lexers/javascript.py | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/pygments/lexers/javascript.py b/pygments/lexers/javascript.py index 8b5f9c76..481243ef 100644 --- a/pygments/lexers/javascript.py +++ b/pygments/lexers/javascript.py @@ -22,6 +22,7 @@ __all__ = ['JavascriptLexer', 'KalLexer', 'LiveScriptLexer', 'DartLexer', 'TypeScriptLexer', 'LassoLexer', 'ObjectiveJLexer', 'CoffeeScriptLexer', 'MaskLexer'] + JS_IDENT_START = ('(?:[$_' + uni.Lu + uni.Ll + uni.Lt + uni.Lm + uni.Lo + uni.Nl + ']|\\\\u[a-fA-F0-9]{4})') JS_IDENT_PART = ('(?:[$_' + uni.Lu + uni.Ll + uni.Lt + uni.Lm + uni.Lo + uni.Nl @@ -29,6 +30,7 @@ JS_IDENT_PART = ('(?:[$_' + uni.Lu + uni.Ll + uni.Lt + uni.Lm + uni.Lo + uni.Nl + u'\u200c\u200d]|\\\\u[a-fA-F0-9]{4})') JS_IDENT = JS_IDENT_START + '(?:' + JS_IDENT_PART + ')*' + class JavascriptLexer(RegexLexer): """ For JavaScript source code. @@ -178,13 +180,13 @@ class KalLexer(RegexLexer): # hashmarks, quotes and backslashes must be parsed one at a time ], 'interpoling_string': [ - (r'}', String.Interpol, "#pop"), + (r'\}', String.Interpol, "#pop"), include('root') ], 'dqs': [ (r'"', String, '#pop'), (r'\\.|\'', String), # double-quoted string don't need ' escapes - (r'#{', String.Interpol, "interpoling_string"), + (r'#\{', String.Interpol, "interpoling_string"), include('strings') ], 'sqs': [ @@ -195,7 +197,7 @@ class KalLexer(RegexLexer): 'tdqs': [ (r'"""', String, '#pop'), (r'\\.|\'|"', String), # no need to escape quotes in triple-string - (r'#{', String.Interpol, "interpoling_string"), + (r'#\{', String.Interpol, "interpoling_string"), include('strings'), ], 'tsqs': [ @@ -287,13 +289,13 @@ class LiveScriptLexer(RegexLexer): # hashmarks, quotes and backslashes must be parsed one at a time ], 'interpoling_string': [ - (r'}', String.Interpol, "#pop"), + (r'\}', String.Interpol, "#pop"), include('root') ], 'dqs': [ (r'"', String, '#pop'), (r'\\.|\'', String), # double-quoted string don't need ' escapes - (r'#{', String.Interpol, "interpoling_string"), + (r'#\{', String.Interpol, "interpoling_string"), (r'#', String), include('strings') ], @@ -305,7 +307,7 @@ class LiveScriptLexer(RegexLexer): 'tdqs': [ (r'"""', String, '#pop'), (r'\\.|\'|"', String), # no need to escape quotes in triple-string - (r'#{', String.Interpol, "interpoling_string"), + (r'#\{', String.Interpol, "interpoling_string"), (r'#', String), include('strings'), ], @@ -1000,7 +1002,7 @@ class CoffeeScriptLexer(RegexLexer): 'multilineregex': [ (r'[^/#]+', String.Regex), (r'///([gim]+\b|\B)', String.Regex, '#pop'), - (r'#{', String.Interpol, 'interpoling_string'), + (r'#\{', String.Interpol, 'interpoling_string'), (r'[/#]', String.Regex), ], 'slashstartsregex': [ @@ -1054,13 +1056,13 @@ class CoffeeScriptLexer(RegexLexer): # hashmarks, quotes and backslashes must be parsed one at a time ], 'interpoling_string': [ - (r'}', String.Interpol, "#pop"), + (r'\}', String.Interpol, "#pop"), include('root') ], 'dqs': [ (r'"', String, '#pop'), (r'\\.|\'', String), # double-quoted string don't need ' escapes - (r'#{', String.Interpol, "interpoling_string"), + (r'#\{', String.Interpol, "interpoling_string"), (r'#', String), include('strings') ], @@ -1072,7 +1074,7 @@ class CoffeeScriptLexer(RegexLexer): 'tdqs': [ (r'"""', String, '#pop'), (r'\\.|\'|"', String), # no need to escape quotes in triple-string - (r'#{', String.Interpol, "interpoling_string"), + (r'#\{', String.Interpol, "interpoling_string"), (r'#', String), include('strings'), ], |