Mercurial > hgrepos > Python > libs > pygments-lexer-pseudocode2
diff pygments_lexer_pseudocode2/algpseudocode.py @ 117:d84f1fd10e64
Allow to customize the symbol for a remark
| author | Franz Glasner <fzglas.hg@dom66.de> |
|---|---|
| date | Wed, 06 May 2026 13:35:12 +0200 |
| parents | 9bfd87544902 |
| children | e39ca08b0609 |
line wrap: on
line diff
--- a/pygments_lexer_pseudocode2/algpseudocode.py Wed May 06 10:05:57 2026 +0200 +++ b/pygments_lexer_pseudocode2/algpseudocode.py Wed May 06 13:35:12 2026 +0200 @@ -111,6 +111,7 @@ DEFAULT_END_PREFIX = "END OF " SYMBOL_REMARK = "▷" # U+25B7: Unicode 1.0 (Geometric Shapes) # SYMBOL_REMARK = "▻" # U+25BB: Unicode 1.0 (Geometric Shapes) + # SYMBOL_REMARK = "⍝" # U+235D: Unicode 1.1 (Misc. Technical, APL) SYMBOL_BLOCK = "◆" # U+25C6: Unicode 1.0 (Geometric Shapes) # SYMBOL_BLOCK = "┃" # U+2503: Unicode 1.0 (Bow Drawing) # SYMBOL_BLOCK = "●" # U+25CF: Unicode 1.0 (Geometric Shapes) @@ -202,6 +203,9 @@ def op_gets(lexer, match, ctx=None): yield match.start(), Operator, lexer.symbol_gets + def op_remark(lexer, match, ctx=None): + yield match.start(), Comment.Single, lexer.symbol_remark + def op_symbol(toktype): def _op_symbol(lexer, match, ctx=None): @@ -332,7 +336,7 @@ ], "remark": [ (r"(?i)\\(remark|rem)\b(.*)$", - bygroups(op_symbol(Comment.Single), Comment.Single)), + bygroups(op_remark, Comment.Single)), ], "entity-name": [ # may be multiline (r"[^\\}]+", Name.Entity), @@ -514,6 +518,9 @@ self.symbol_gets = options.get("gets", None) if self.symbol_gets is None: self.symbol_gets = self.SYMBOLS["<-"] # Default: "⟵" # U+27F5 + self.symbol_remark = options.get("remark", None) + if self.symbol_remark is None: + self.symbol_remark = self.SYMBOLS["REM"] # Default: "▷" # U+25B7 LexBase.__init__(self, **options)
