changeset 108:6cebd3e7bc97

Also allow \REM within a \TEXT{}
author Franz Glasner <fzglas.hg@dom66.de>
date Mon, 04 May 2026 17:36:13 +0200
parents 1c1985532139
children 49e5aa89095f
files docs/algorithm-ford-fulkerson.pseudocode pygments_lexer_pseudocode2/algpseudocode.py tests/test_algpseudo.py
diffstat 3 files changed, 18 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/docs/algorithm-ford-fulkerson.pseudocode	Mon May 04 16:57:17 2026 +0200
+++ b/docs/algorithm-ford-fulkerson.pseudocode	Mon May 04 17:36:13 2026 +0200
@@ -12,8 +12,8 @@
 
      2. For each edge \expr{(u, v) ∈ p}
 
-        1. \expr{f(u, v) <- f(u, v) + c_f(p)}   \expr{\rem Send flow along the path
+        1. \expr{f(u, v) <- f(u, v) + c_f(p)}   \rem Send flow along the path
 
-}	2. \expr{f(v, u) <- f(v, u) - c_f(p)}   \expr{\rem The flow might be "returned" later
-}}
+	2. \expr{f(v, u) <- f(v, u) - c_f(p)}   \rem The flow might be "returned" later
+}
 \END ALGORITHM {Ford–Fulkerson}
--- a/pygments_lexer_pseudocode2/algpseudocode.py	Mon May 04 16:57:17 2026 +0200
+++ b/pygments_lexer_pseudocode2/algpseudocode.py	Mon May 04 17:36:13 2026 +0200
@@ -235,7 +235,7 @@
             (r"(?i)\\("
              r"(?:input(?:s)?)"
              r"|(?:output(?:s)?)"
-             r"|(?:ensure)"             
+             r"|(?:ensure)"
              r"|(?:returns)"
              r")[ \t]*(\{)",
              bygroups(op_translate(Keyword),
@@ -397,6 +397,7 @@
              LexBase.op_ignore,
              "block-expr"),
             include("explicit-tokentype"),
+            include("remark"),
             (r"\\\\", LexBase.op_fixed(Text, "\\")),
             (r"\\", LexBase.op_fixed(Text, "\\")),
             (r".", Generic.Error),     # tolerance for errors
--- a/tests/test_algpseudo.py	Mon May 04 16:57:17 2026 +0200
+++ b/tests/test_algpseudo.py	Mon May 04 17:36:13 2026 +0200
@@ -330,6 +330,19 @@
 \\Rem  the remark 2
 """, self.lexer))
 
+    def test_remark_in_text(self):
+        self.assertTokenStreamEqualComplete(
+            [("Text", "the text  "),
+             ("Comment.Single", "▷"),
+             ("Comment.Single", " the remark"),
+             ("Text.Whitespace", "\n"),
+             ("Text", "the next text line"),
+             ("Text.Whitespace", "\n"),
+             ],
+            pygments.lex(
+                """\\TEXT{the text  \\rem the remark\nthe next text line}""",
+                self.lexer))
+
     def test_comment_single_1(self):
         self.assertTokenStreamEqualComplete(
             [("Comment.Single", "// foo bar"),