# HG changeset patch # User Franz Glasner # Date 1778253206 -7200 # Node ID 4ee0b1536ea663770074d6d46bca4e8a8c0968cc # Parent f08d77b8cbf7aa566466b7f9a963673baba565d4 Handle runs of dots in expressions (., .., ..., ...., ...) diff -r f08d77b8cbf7 -r 4ee0b1536ea6 docs/details-algpseudocode.rst --- a/docs/details-algpseudocode.rst Fri May 08 16:44:30 2026 +0200 +++ b/docs/details-algpseudocode.rst Fri May 08 17:13:26 2026 +0200 @@ -137,6 +137,14 @@ and highlighted accordingly. +Punctuation +=========== + +Runs of dots ``.``, ``..``, ``...``, ``....``, ... are handled +properly in expressions and yield a punctuation token. +They are not replaced by corresponding Unicode symbols. + + Keywords ======== diff -r f08d77b8cbf7 -r 4ee0b1536ea6 docs/intro.rst --- a/docs/intro.rst Fri May 08 16:44:30 2026 +0200 +++ b/docs/intro.rst Fri May 08 17:13:26 2026 +0200 @@ -112,7 +112,8 @@ :lines: 2- This is Wikipedia's pseudocode of the *Edmonds–Karp Algorithm* -(see https://en.wikipedia.org/wiki/Edmonds%E2%80%93Karp_algorithm): +(see https://en.wikipedia.org/wiki/Edmonds%E2%80%93Karp_algorithm) +with a custom lexer that skip all ``ENDxxx`` keywords: .. literalinclude:: examples/algorithm-edmonds-karp.pseudocode :language: NoEndAlgPseudocode diff -r f08d77b8cbf7 -r 4ee0b1536ea6 pygments_lexer_pseudocode2/algpseudocode.py --- a/pygments_lexer_pseudocode2/algpseudocode.py Fri May 08 16:44:30 2026 +0200 +++ b/pygments_lexer_pseudocode2/algpseudocode.py Fri May 08 17:13:26 2026 +0200 @@ -461,6 +461,7 @@ Keyword.Constant), ], "ascii-punctuation": [ + (r"\.+", Punctuation), (r"[{}:(),;[\]?@]", Punctuation), ], "ascii-punctuation-in-braces": [ diff -r f08d77b8cbf7 -r 4ee0b1536ea6 tests/test_algpseudo.py --- a/tests/test_algpseudo.py Fri May 08 16:44:30 2026 +0200 +++ b/tests/test_algpseudo.py Fri May 08 17:13:26 2026 +0200 @@ -1003,6 +1003,34 @@ pygments.lex(r"(* word1 * word2 ( word3 ) word4 () word5 *)", self.lexer)) + def test_dots_one(self): + self.assertTokenStreamEqualComplete( + [("Punctuation", "."), + ("Text.Whitespace", "\n"), + ], + pygments.lex(r".", self.lexer)) + + def test_dots_two(self): + self.assertTokenStreamEqualComplete( + [("Punctuation", ".."), + ("Text.Whitespace", "\n"), + ], + pygments.lex(r"..", self.lexer)) + + def test_dots_three(self): + self.assertTokenStreamEqualComplete( + [("Punctuation", "..."), + ("Text.Whitespace", "\n"), + ], + pygments.lex(r"...", self.lexer)) + + def test_dots_four(self): + self.assertTokenStreamEqualComplete( + [("Punctuation", "...."), + ("Text.Whitespace", "\n"), + ], + pygments.lex(r"....", self.lexer)) + class PygmentizeCompletely(unittest.TestCase):