Mercurial > hgrepos > Python > libs > pygments-lexer-pseudocode2
comparison 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 |
comparison
equal
deleted
inserted
replaced
| 116:9bfd87544902 | 117:d84f1fd10e64 |
|---|---|
| 109 "LOOP": "END LOOP", | 109 "LOOP": "END LOOP", |
| 110 } | 110 } |
| 111 DEFAULT_END_PREFIX = "END OF " | 111 DEFAULT_END_PREFIX = "END OF " |
| 112 SYMBOL_REMARK = "▷" # U+25B7: Unicode 1.0 (Geometric Shapes) | 112 SYMBOL_REMARK = "▷" # U+25B7: Unicode 1.0 (Geometric Shapes) |
| 113 # SYMBOL_REMARK = "▻" # U+25BB: Unicode 1.0 (Geometric Shapes) | 113 # SYMBOL_REMARK = "▻" # U+25BB: Unicode 1.0 (Geometric Shapes) |
| 114 # SYMBOL_REMARK = "⍝" # U+235D: Unicode 1.1 (Misc. Technical, APL) | |
| 114 SYMBOL_BLOCK = "◆" # U+25C6: Unicode 1.0 (Geometric Shapes) | 115 SYMBOL_BLOCK = "◆" # U+25C6: Unicode 1.0 (Geometric Shapes) |
| 115 # SYMBOL_BLOCK = "┃" # U+2503: Unicode 1.0 (Bow Drawing) | 116 # SYMBOL_BLOCK = "┃" # U+2503: Unicode 1.0 (Bow Drawing) |
| 116 # SYMBOL_BLOCK = "●" # U+25CF: Unicode 1.0 (Geometric Shapes) | 117 # SYMBOL_BLOCK = "●" # U+25CF: Unicode 1.0 (Geometric Shapes) |
| 117 SYMBOL_TEXTSTATEMENT = "▪" # U+25AA: Unicode 1.0 (Geometric Shapes) | 118 SYMBOL_TEXTSTATEMENT = "▪" # U+25AA: Unicode 1.0 (Geometric Shapes) |
| 118 # SYMBOL_TEXTSTATEMENT = "■" # U+25A0: Unicode 1.0 (Geometric Shapes) | 119 # SYMBOL_TEXTSTATEMENT = "■" # U+25A0: Unicode 1.0 (Geometric Shapes) |
| 199 | 200 |
| 200 return _op_opt_ignore_or_fixed | 201 return _op_opt_ignore_or_fixed |
| 201 | 202 |
| 202 def op_gets(lexer, match, ctx=None): | 203 def op_gets(lexer, match, ctx=None): |
| 203 yield match.start(), Operator, lexer.symbol_gets | 204 yield match.start(), Operator, lexer.symbol_gets |
| 205 | |
| 206 def op_remark(lexer, match, ctx=None): | |
| 207 yield match.start(), Comment.Single, lexer.symbol_remark | |
| 204 | 208 |
| 205 def op_symbol(toktype): | 209 def op_symbol(toktype): |
| 206 | 210 |
| 207 def _op_symbol(lexer, match, ctx=None): | 211 def _op_symbol(lexer, match, ctx=None): |
| 208 kw = match.group().upper() | 212 kw = match.group().upper() |
| 330 (r"[^\S\n]+", Text), | 334 (r"[^\S\n]+", Text), |
| 331 (r".", Generic.Error), # tolerance for errors | 335 (r".", Generic.Error), # tolerance for errors |
| 332 ], | 336 ], |
| 333 "remark": [ | 337 "remark": [ |
| 334 (r"(?i)\\(remark|rem)\b(.*)$", | 338 (r"(?i)\\(remark|rem)\b(.*)$", |
| 335 bygroups(op_symbol(Comment.Single), Comment.Single)), | 339 bygroups(op_remark, Comment.Single)), |
| 336 ], | 340 ], |
| 337 "entity-name": [ # may be multiline | 341 "entity-name": [ # may be multiline |
| 338 (r"[^\\}]+", Name.Entity), | 342 (r"[^\\}]+", Name.Entity), |
| 339 (r"\}", LexBase.op_ignore, "#pop"), | 343 (r"\}", LexBase.op_ignore, "#pop"), |
| 340 (r"\\\}", LexBase.op_fixed(Name.Entity, "}")), | 344 (r"\\\}", LexBase.op_fixed(Name.Entity, "}")), |
| 512 self.no_end = pygments.util.get_bool_opt( | 516 self.no_end = pygments.util.get_bool_opt( |
| 513 options, "no_end", default=False) | 517 options, "no_end", default=False) |
| 514 self.symbol_gets = options.get("gets", None) | 518 self.symbol_gets = options.get("gets", None) |
| 515 if self.symbol_gets is None: | 519 if self.symbol_gets is None: |
| 516 self.symbol_gets = self.SYMBOLS["<-"] # Default: "⟵" # U+27F5 | 520 self.symbol_gets = self.SYMBOLS["<-"] # Default: "⟵" # U+27F5 |
| 521 self.symbol_remark = options.get("remark", None) | |
| 522 if self.symbol_remark is None: | |
| 523 self.symbol_remark = self.SYMBOLS["REM"] # Default: "▷" # U+25B7 | |
| 517 LexBase.__init__(self, **options) | 524 LexBase.__init__(self, **options) |
| 518 | 525 |
| 519 | 526 |
| 520 class AlgPseudocodeLexer_DE(AlgPseudocodeLexer): | 527 class AlgPseudocodeLexer_DE(AlgPseudocodeLexer): |
| 521 | 528 |
