Mercurial > hgrepos > Python > libs > pygments-lexer-pseudocode2
changeset 83:cd79d2c76347
If a Pygments callback gets a "Context" it must set the new position explicitely.
This is **not** done automatically.
| author | Franz Glasner <fzglas.hg@dom66.de> |
|---|---|
| date | Thu, 30 Apr 2026 13:21:38 +0200 |
| parents | 36a0ef76a6d7 |
| children | 3ac1c4502ad0 |
| files | pygments_lexer_pseudocode2/algpseudocode.py pygments_lexer_pseudocode2/bases.py |
| diffstat | 2 files changed, 14 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/pygments_lexer_pseudocode2/algpseudocode.py Thu Apr 30 12:29:08 2026 +0200 +++ b/pygments_lexer_pseudocode2/algpseudocode.py Thu Apr 30 13:21:38 2026 +0200 @@ -99,6 +99,8 @@ def _op_translate(lexer, match, ctx=None): kw = match.group().upper() yield match.start(), toktype, lexer.TRANSLATIONS.get(kw, kw) + if ctx: + ctx.pos = match.end() return _op_translate @@ -112,6 +114,8 @@ lexer.END_TRANSLATIONS.get( kw, lexer.DEFAULT_END_PREFIX + kw)) + if ctx: + ctx.pos = match.end() return _op_end_translate @@ -120,6 +124,8 @@ def _op_opt_ignore(lexer, match, ctx=None): if not lexer.no_end: yield match.start(), toktype, match.group() + if ctx: + ctx.pos = match.end() return _op_opt_ignore @@ -132,6 +138,8 @@ def _op_opt_ignore_or_fixed(lexer, match, ctx=None): if not lexer.no_end: yield match.start(), toktype, value + if ctx: + ctx.pos = match.end() return _op_opt_ignore_or_fixed @@ -140,6 +148,8 @@ def _op_symbol(lexer, match, ctx=None): kw = match.group().upper() yield match.start(), toktype, lexer.SYMBOLS.get(kw, kw) + if ctx: + ctx.pos = match.end() return _op_symbol
--- a/pygments_lexer_pseudocode2/bases.py Thu Apr 30 12:29:08 2026 +0200 +++ b/pygments_lexer_pseudocode2/bases.py Thu Apr 30 13:21:38 2026 +0200 @@ -85,6 +85,8 @@ """Unconditionally ignore the match.""" if False: yield match.start(), Other, "" + if ctx: + ctx.pos = match.end() @_staticmethod def op_fixed(toktype, value): @@ -92,6 +94,8 @@ def _op_fixed(lexer, match, ctx=None): yield match.start(), toktype, value + if ctx: + ctx.pos = match.end() return _op_fixed
