diff options
author | Georg Brandl <georg@python.org> | 2017-01-22 21:01:13 +0000 |
---|---|---|
committer | Georg Brandl <georg@python.org> | 2017-01-22 21:01:13 +0000 |
commit | a82f7a4953bcbc16813b18d761d91dd215149c0d (patch) | |
tree | 8e461f642654bd47f2fcb60b60891923529670a1 | |
parent | 46990cfbbf5ae300abe27375cb03d319e696067f (diff) | |
parent | a364d3742833e2b12d54622b317f7b1187594bf4 (diff) | |
download | pygments-a82f7a4953bcbc16813b18d761d91dd215149c0d.tar.gz |
Merged in chipx86/pygments-main/typescript-vs-typoscript (pull request #693)
Implement guessing and resolution between TypeScript and TypoScript.
-rw-r--r-- | pygments/lexers/javascript.py | 8 | ||||
-rw-r--r-- | pygments/lexers/typoscript.py | 3 |
2 files changed, 10 insertions, 1 deletions
diff --git a/pygments/lexers/javascript.py b/pygments/lexers/javascript.py index 7dbaaff6..862535c9 100644 --- a/pygments/lexers/javascript.py +++ b/pygments/lexers/javascript.py @@ -448,7 +448,7 @@ class TypeScriptLexer(RegexLexer): name = 'TypeScript' aliases = ['ts', 'typescript'] - filenames = ['*.ts'] + filenames = ['*.ts', '*.tsx'] mimetypes = ['text/x-typescript'] flags = re.DOTALL | re.MULTILINE @@ -534,6 +534,12 @@ 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): """ diff --git a/pygments/lexers/typoscript.py b/pygments/lexers/typoscript.py index d9adb4ad..e358af07 100644 --- a/pygments/lexers/typoscript.py +++ b/pygments/lexers/typoscript.py @@ -113,6 +113,9 @@ class TypoScriptLexer(RegexLexer): flags = re.DOTALL | re.MULTILINE + # Slightly higher than TypeScript (which is 0). + priority = 0.1 + tokens = { 'root': [ include('comment'), |