# HG changeset patch # User Franz Glasner # Date 1779220450 -7200 # Node ID 9790553d7225febe3b8b3504f6e162f886aad8b7 # Parent ea19b621081d47eb64a032d2a63962b4759b4b72 More details on custom filters in the documentation diff -r ea19b621081d -r 9790553d7225 docs/filters.rst --- 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 ============================== diff -r ea19b621081d -r 9790553d7225 docs/lexer-algpseudocode.rst --- 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.