Mercurial > hgrepos > Python > libs > pygments-lexer-pseudocode2
changeset 275:f365d9d2c0ad
FIX: explicit token types: backslash as separator now correctly handled
| author | Franz Glasner <fzglas.hg@dom66.de> |
|---|---|
| date | Wed, 20 May 2026 10:16:58 +0200 |
| parents | 77cfab93a60e |
| children | 397ed930a5ba |
| files | pygments_lexer_pseudocode2/lexers/algpseudocode.py tests/test_algpseudo.py |
| diffstat | 2 files changed, 11 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/pygments_lexer_pseudocode2/lexers/algpseudocode.py Wed May 20 09:51:29 2026 +0200 +++ b/pygments_lexer_pseudocode2/lexers/algpseudocode.py Wed May 20 10:16:58 2026 +0200 @@ -491,7 +491,7 @@ # All these REs are CASE-SENSITIVE! # Multiple characters possible, but no escaping! - (r"\\ttx\-(?P<type>[a-zA-Z0-9_-]+?)(?P<sep>[/:|=*+!\$~])" + (r"\\ttx\-(?P<type>[a-zA-Z0-9_-]+?)(?P<sep>[/:|=*+!\\$~])" r"(?P<character>(.|\n)+?)(?P=sep)", op_explicit_tokentype), (r"\\ttx\-(?P<type>[a-zA-Z0-9_-]+?)\{(?P<character>[^}]+?)\}",
--- a/tests/test_algpseudo.py Wed May 20 09:51:29 2026 +0200 +++ b/tests/test_algpseudo.py Wed May 20 10:16:58 2026 +0200 @@ -699,6 +699,16 @@ r"""\ttx-nd[a_Decorator](p1, p2) \rem (Python) annotation""", self.lexer)) + def test_explicit_tokentype_all_seps(self): + for sep in r"/:|=*+!\$~": + self.assertTokenStreamEqualComplete( + [("Name.Decorator", "word"), + ("Text.Whitespace", "\n"), + ], + pygments.lex( + r"\ttx-nd%sword%s" % (sep, sep,), + self.lexer)) + def test_explicit_tokentype_error(self): self.assertTokenStreamEqualComplete( [("Generic.Error", r"""\ttx-non-existing[a_Decorator]"""),
