summaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
authorWalter Dörwald <walter@livinglogic.de>2021-12-28 18:12:45 +0100
committerGitHub <noreply@github.com>2021-12-28 18:12:45 +0100
commit34bf90dcfc8fc32fca8b84e4c56b2805fc0dd82f (patch)
tree8a1bfef947a6b4b52434ecadea7b793acbe0f86c /doc
parent7dea301f7f3baa2c5a585a90ab8d8c30332ef562 (diff)
downloadpygments-git-34bf90dcfc8fc32fca8b84e4c56b2805fc0dd82f.tar.gz
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.
Diffstat (limited to 'doc')
-rw-r--r--doc/docs/lexerdevelopment.rst14
1 files changed, 11 insertions, 3 deletions
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 <inputfile>
-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 <inputfile>
+
+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.