diff options
author | Max Horn <max@quendi.de> | 2022-08-19 22:19:14 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-08-19 22:19:14 +0200 |
commit | f4976545a11bb126cf201b5942f543359a03cc58 (patch) | |
tree | 385e265bc62499f1fe447cc460d6eef0793d6532 /pygments/lexers/matlab.py | |
parent | adb90dc65f2f211675af5be27d2a7efdf96c6f44 (diff) | |
download | pygments-git-f4976545a11bb126cf201b5942f543359a03cc58.tar.gz |
Add GAP console session mode (#2211)
* Add GAP console session mode
This is also appropriate for GAP .tst files.
Add `analyse_text` methods for `ScilabLexer` and `GAPConsoleLexer` to
distinguish Scilab and GAP .tst files
* Use explicit name for 'keepends' argument to splitlines
Diffstat (limited to 'pygments/lexers/matlab.py')
-rw-r--r-- | pygments/lexers/matlab.py | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/pygments/lexers/matlab.py b/pygments/lexers/matlab.py index b70058c5..058661ee 100644 --- a/pygments/lexers/matlab.py +++ b/pygments/lexers/matlab.py @@ -3294,3 +3294,15 @@ class ScilabLexer(RegexLexer): (r'(\s*)([a-zA-Z_]\w*)', bygroups(Text, Name.Function), '#pop'), ], } + + # the following is needed to distinguish Scilab and GAP .tst files + def analyse_text(text): + score = 0.0 + + # Scilab comments (don't appear in e.g. GAP code) + if re.search(r"^\s*//", text): + score += 0.1 + if re.search(r"^\s*/\*", text): + score += 0.1 + + return min(score, 1.0) |