Mercurial > hgrepos > Python > libs > pygments-lexer-pseudocode2
comparison 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 |
comparison
equal
deleted
inserted
replaced
| 257:265b759f1f08 | 258:e03e8cfdcece |
|---|---|
| 51 | 51 |
| 52 TokenReplaceFilter | 52 TokenReplaceFilter |
| 53 ================== | 53 ================== |
| 54 | 54 |
| 55 :Name: tokenreplace | 55 :Name: tokenreplace |
| 56 :Required Filter Options: | 56 :Filter Options: |
| 57 ``replacements`` | |
| 58 **Type:** :py:class:`dict[str | pygments.token.Token, str | pygments.token.Token]` | |
| 59 | |
| 60 A map from tokens to their replacements. | |
| 61 | |
| 57 ``token_from`` | 62 ``token_from`` |
| 58 **Type:** :py:class:`str` or :py:class:`pygments.token.Token` | 63 **Type:** :py:class:`str` or :py:class:`pygments.token.Token` |
| 59 | 64 |
| 60 The name of a token type (like ``Error``) or a token object | 65 The name of a token type (like ``Error``) or a token object |
| 61 (like :py:class:`pygments.token.Token.Error`). | 66 (like :py:class:`pygments.token.Token.Error`). |
| 67 | |
| 68 If given the `token_to` options is required and `replacements` will be | |
| 69 augmented with their respective values. | |
| 62 | 70 |
| 63 ``token_to`` | 71 ``token_to`` |
| 64 **Type:** :py:class:`str` or :py:class:`pygments.token.Token` | 72 **Type:** :py:class:`str` or :py:class:`pygments.token.Token` |
| 65 | 73 |
| 66 The name of a token type (like ``Generic.Error``) or a token object | 74 The name of a token type (like ``Generic.Error``) or a token object |
| 67 (like :py:class:`pygments.token.Token.Generic.Error`). | 75 (like :py:class:`pygments.token.Token.Generic.Error`). |
| 68 | 76 |
| 69 Replace all token types given in `token_from` by the token type given | 77 This option is required if `token_from` is given. |
| 70 in `token_to`. | 78 |
| 79 Replace all token types given as `replacements` keys or in `token_from` | |
| 80 with the token types given in `replacements` values or in `token_to`. | |
| 81 | |
| 82 The values in the token stream are retained. |
