Mercurial > hgrepos > Python > libs > pygments-lexer-pseudocode2
changeset 269:9790553d7225
More details on custom filters in the documentation
| author | Franz Glasner <fzglas.hg@dom66.de> |
|---|---|
| date | Tue, 19 May 2026 21:54:10 +0200 |
| parents | ea19b621081d |
| children | cb66de44a7b9 |
| files | docs/filters.rst docs/lexer-algpseudocode.rst |
| diffstat | 2 files changed, 23 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/docs/filters.rst Tue May 19 21:11:28 2026 +0200 +++ b/docs/filters.rst Tue May 19 21:54:10 2026 +0200 @@ -1,12 +1,14 @@ .. -*- coding: utf-8; indent-tabs-mode: nil; -*- +.. _filters: + ********* Filters ********* .. only:: html - .. contents:: + .. contents:: The package contains the following filters: @@ -20,8 +22,9 @@ } -The AlgPseudocode lexer yields an error token for the following code block. -`Sphinx`_ warns about this and---as a consequence--- suppresses highlighting +The "normal" AlgPseudocode lexer yields an error token for the code block +below; +`Sphinx`_ warns about this and---as a consequence---suppresses highlighting for this code block completely: .. code-block:: none @@ -43,6 +46,21 @@ \nonexisting{TEST} +The above custom lexer has been defined for `Sphinx`_ using: + +.. code-block:: python + + import functools + from pygments_lexer_pseudocode2.filters import ErrorToGenericErrorTokenFilter + from pygments_lexer_pseudocode2.lexers.algpseudocode import AlgPseudocodeLexer + + def setup(app): + app.add_lexer( + "genericerror-algpseudocode", + functools.partial( + AlgPseudocodeLexer, + filters=[ErrorToGenericErrorTokenFilter])) + ErrorToGenericErrorTokenFilter ==============================
--- a/docs/lexer-algpseudocode.rst Tue May 19 21:11:28 2026 +0200 +++ b/docs/lexer-algpseudocode.rst Tue May 19 21:54:10 2026 +0200 @@ -586,6 +586,8 @@ :py:data:`sphinx.highlighting.lexers` somehow are taken as is by Sphinx and are not augmented with any default filters. + For more details see chapter :ref:`filters`. + For older Sphinx versions your mileage may vary.
