Mercurial > hgrepos > Python > libs > pygments-lexer-pseudocode2
diff docs/filters.rst @ 258:e03e8cfdcece
Make the TokenReplaceFilter more flexible by allowing a replacement map
| author | Franz Glasner <fzglas.hg@dom66.de> |
|---|---|
| date | Sun, 17 May 2026 16:08:34 +0200 |
| parents | 4e4c83a87387 |
| children | e5ea2f955986 |
line wrap: on
line diff
--- a/docs/filters.rst Sun May 17 14:30:07 2026 +0200 +++ b/docs/filters.rst Sun May 17 16:08:34 2026 +0200 @@ -53,18 +53,30 @@ ================== :Name: tokenreplace -:Required Filter Options: +:Filter Options: + ``replacements`` + **Type:** :py:class:`dict[str | pygments.token.Token, str | pygments.token.Token]` + + A map from tokens to their replacements. + ``token_from`` **Type:** :py:class:`str` or :py:class:`pygments.token.Token` The name of a token type (like ``Error``) or a token object (like :py:class:`pygments.token.Token.Error`). + If given the `token_to` options is required and `replacements` will be + augmented with their respective values. + ``token_to`` **Type:** :py:class:`str` or :py:class:`pygments.token.Token` The name of a token type (like ``Generic.Error``) or a token object (like :py:class:`pygments.token.Token.Generic.Error`). -Replace all token types given in `token_from` by the token type given -in `token_to`. + This option is required if `token_from` is given. + +Replace all token types given as `replacements` keys or in `token_from` +with the token types given in `replacements` values or in `token_to`. + +The values in the token stream are retained.
