summaryrefslogtreecommitdiff
path: root/pygments/lexers/javascript.py
diff options
context:
space:
mode:
Diffstat (limited to 'pygments/lexers/javascript.py')
-rw-r--r--pygments/lexers/javascript.py22
1 files changed, 11 insertions, 11 deletions
diff --git a/pygments/lexers/javascript.py b/pygments/lexers/javascript.py
index 862535c9..e61c451e 100644
--- a/pygments/lexers/javascript.py
+++ b/pygments/lexers/javascript.py
@@ -5,7 +5,7 @@
Lexers for JavaScript and related languages.
- :copyright: Copyright 2006-2017 by the Pygments team, see AUTHORS.
+ :copyright: Copyright 2006-2019 by the Pygments team, see AUTHORS.
:license: BSD, see LICENSE for details.
"""
@@ -453,6 +453,10 @@ class TypeScriptLexer(RegexLexer):
flags = re.DOTALL | re.MULTILINE
+ # Higher priority than the TypoScriptLexer, as TypeScript is far more
+ # common these days
+ priority = 0.5
+
tokens = {
'commentsandwhitespace': [
(r'\s+', Text),
@@ -478,7 +482,7 @@ class TypeScriptLexer(RegexLexer):
(r'[{(\[;,]', Punctuation, 'slashstartsregex'),
(r'[})\].]', Punctuation),
(r'(for|in|while|do|break|return|continue|switch|case|default|if|else|'
- r'throw|try|catch|finally|new|delete|typeof|instanceof|void|'
+ r'throw|try|catch|finally|new|delete|typeof|instanceof|void|of|'
r'this)\b', Keyword, 'slashstartsregex'),
(r'(var|let|with|function)\b', Keyword.Declaration, 'slashstartsregex'),
(r'(abstract|boolean|byte|char|class|const|debugger|double|enum|export|'
@@ -534,12 +538,6 @@ class TypeScriptLexer(RegexLexer):
],
}
- def analyse_text(text):
- if re.search('^(import.+(from\s+)?["\']|'
- '(export\s*)?(interface|class|function)\s+)',
- text, re.MULTILINE):
- return 1.0
-
class LassoLexer(RegexLexer):
"""
@@ -1015,7 +1013,7 @@ class ObjectiveJLexer(RegexLexer):
}
def analyse_text(text):
- if re.search('^\s*@import\s+[<"]', text, re.MULTILINE):
+ if re.search(r'^\s*@import\s+[<"]', text, re.MULTILINE):
# special directive found in most Objective-J files
return True
return False
@@ -1500,8 +1498,10 @@ class JuttleLexer(RegexLexer):
(r'^(?=\s|/)', Text, 'slashstartsregex'),
include('commentsandwhitespace'),
(r':\d{2}:\d{2}:\d{2}(\.\d*)?:', String.Moment),
- (r':(now|beginning|end|forever|yesterday|today|tomorrow|(\d+(\.\d*)?|\.\d+)(ms|[smhdwMy])?):', String.Moment),
- (r':\d{4}-\d{2}-\d{2}(T\d{2}:\d{2}:\d{2}(\.\d*)?)?(Z|[+-]\d{2}:\d{2}|[+-]\d{4})?:', String.Moment),
+ (r':(now|beginning|end|forever|yesterday|today|tomorrow|'
+ r'(\d+(\.\d*)?|\.\d+)(ms|[smhdwMy])?):', String.Moment),
+ (r':\d{4}-\d{2}-\d{2}(T\d{2}:\d{2}:\d{2}(\.\d*)?)?'
+ r'(Z|[+-]\d{2}:\d{2}|[+-]\d{4})?:', String.Moment),
(r':((\d+(\.\d*)?|\.\d+)[ ]+)?(millisecond|second|minute|hour|day|week|month|year)[s]?'
r'(([ ]+and[ ]+(\d+[ ]+)?(millisecond|second|minute|hour|day|week|month|year)[s]?)'
r'|[ ]+(ago|from[ ]+now))*:', String.Moment),