diff options
author | Georg Brandl <georg@python.org> | 2021-03-01 11:47:34 +0100 |
---|---|---|
committer | Georg Brandl <georg@python.org> | 2021-03-01 11:47:34 +0100 |
commit | 506708f1f0ff9452fe7d0e2613cc54629903bb1a (patch) | |
tree | ab3eb9d754c89c7f476bf91292634e3130dbc943 | |
parent | ec83fdf152e35cb338bf2738d9ce2d6c1c38c2d5 (diff) | |
download | pygments-git-506708f1f0ff9452fe7d0e2613cc54629903bb1a.tar.gz |
octave: also allow percent block comments
-rw-r--r-- | pygments/lexers/matlab.py | 11 | ||||
-rw-r--r-- | tests/snippets/octave/test_multilinecomment.txt | 9 |
2 files changed, 18 insertions, 2 deletions
diff --git a/pygments/lexers/matlab.py b/pygments/lexers/matlab.py index 2e5db693..e12303dd 100644 --- a/pygments/lexers/matlab.py +++ b/pygments/lexers/matlab.py @@ -3145,7 +3145,8 @@ class OctaveLexer(RegexLexer): tokens = { 'root': [ - (r'%\{\s*\n', Comment.Multiline, 'blockcomment'), + (r'%\{\s*\n', Comment.Multiline, 'percentblockcomment'), + (r'#\{\s*\n', Comment.Multiline, 'hashblockcomment'), (r'[%#].*$', Comment), (r'^\s*function\b', Keyword, 'deffunc'), @@ -3192,13 +3193,19 @@ class OctaveLexer(RegexLexer): (r'(?<![\w)\].])\'', String, 'string'), (r'[a-zA-Z_]\w*', Name), + (r'\s+', Text), (r'.', Text), ], - 'blockcomment': [ + 'percentblockcomment': [ (r'^\s*%\}', Comment.Multiline, '#pop'), (r'^.*\n', Comment.Multiline), (r'.', Comment.Multiline), ], + 'hashblockcomment': [ + (r'^\s*#\}', Comment.Multiline, '#pop'), + (r'^.*\n', Comment.Multiline), + (r'.', Comment.Multiline), + ], 'string': [ (r"[^']*'", String, '#pop'), ], diff --git a/tests/snippets/octave/test_multilinecomment.txt b/tests/snippets/octave/test_multilinecomment.txt index 4d03d51e..0987f4e7 100644 --- a/tests/snippets/octave/test_multilinecomment.txt +++ b/tests/snippets/octave/test_multilinecomment.txt @@ -2,6 +2,9 @@ %{ This is a long comment %} + #{ +This too +#} This isnt ---tokens--- @@ -10,6 +13,12 @@ This isnt 'This is a long comment\n' Comment.Multiline ' %}' Comment.Multiline +'\n ' Text +'#{\n' Comment.Multiline + +'This too\n' Comment.Multiline + +'#}' Comment.Multiline '\n' Text 'This' Name |