Mercurial > hgrepos > Python > libs > pygments-lexer-pseudocode2
diff docs/filters.rst @ 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 | 683c4b35ed26 |
| children | cb66de44a7b9 |
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 ==============================
