From 34bf90dcfc8fc32fca8b84e4c56b2805fc0dd82f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Walter=20D=C3=B6rwald?= Date: Tue, 28 Dec 2021 18:12:45 +0100 Subject: Add a tooltips option to HtmlFormatter. (#1822) * Add a tooltips option to HtmlFormmater. * Rename option tooltips to debug_token_types. * Use explicit if block. * Fix check. * Document how to use the new debug_token_types option for the HTML formatter. * Remove output redirection from example call. --- doc/docs/lexerdevelopment.rst | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'doc') diff --git a/doc/docs/lexerdevelopment.rst b/doc/docs/lexerdevelopment.rst index ccaa2203..720a804b 100644 --- a/doc/docs/lexerdevelopment.rst +++ b/doc/docs/lexerdevelopment.rst @@ -114,9 +114,6 @@ To specify a class name other than CustomLexer, append it with a colon: $ python -m pygments -x -l your_lexer.py:SomeLexer -Use the ``-f`` flag to select a different output format than terminal -escape sequences. - Or, using the Python API: .. code-block:: python @@ -133,6 +130,17 @@ trusted files; Pygments will perform the equivalent of ``eval`` on them. If you only want to use your lexer with the Pygments API, you can import and instantiate the lexer yourself, then pass it to :func:`pygments.highlight`. +Use the ``-f`` flag to select a different output format than terminal +escape sequences. The :class:`pygments.formatters.html.HtmlFormatter` helps +you with debugging your lexer. You can use the ``debug_token_types`` option +to display the token types assigned to each part of your input file: + +.. code-block:: console + + $ python -m pygments -x -f html -Ofull,debug_token_types -l your_lexer.py:SomeLexer + +Hover over each token to see the token type displayed as a tooltip. + To prepare your new lexer for inclusion in the Pygments distribution, so that it will be found when passing filenames or lexer aliases from the command line, you have to perform the following steps. -- cgit v1.2.1