Mercurial > hgrepos > Python > libs > pygments-lexer-pseudocode2
diff docs/lexer-algpseudocode.rst @ 209:f20177032d21
A chapter about escaping rules
| author | Franz Glasner <fzglas.hg@dom66.de> |
|---|---|
| date | Wed, 13 May 2026 15:57:26 +0200 |
| parents | de7118d299e9 |
| children | 18553f595b34 |
line wrap: on
line diff
--- a/docs/lexer-algpseudocode.rst Wed May 13 15:56:58 2026 +0200 +++ b/docs/lexer-algpseudocode.rst Wed May 13 15:57:26 2026 +0200 @@ -252,11 +252,10 @@ * Parameters are separated from the keyword/command by a (possibly empty) run of space or TAB characters. This is true for required and optional parameters. - - .. todo:: Escaping +- Unrecognized commands typically result in a + :py:class:`pygments.token.Token.Error` token. - A single backslash yields a Generic.Error token when in - `default` and `expression` states. +More on escaping rules you can find in :ref:`this chapter <escaping-rules>`. Commands With Required Parameters @@ -491,6 +490,33 @@ .. note:: Explicit token types are **case-sensitive**. +.. _escaping-rules: + +Escaping Rules +============== + +The escape character is a backslash ``\``. + +A backslash can be escaped with ``\\`` and yields a single backslash token. + +Within parameters a closing curly brace ``}`` ends the current +parameters environment. +It must be escaped using ``\}`` if a closing curly brace is part of the +argument content. + +A single backslash yields a :py:class:`pygments.token.Token.Generic.Error` +token when in `default` and `expression` states. +Contrary---in `text` contexts a single backslash character that does not +introduce a command yields a normal text token. + +In all contexts a backslash that would normally introduce a known command +must be escaped if the content should not recognized as a command. + +Single- and double-quotes must be escaped also (``\"`` or ``\'``) in +`default` and `expression` contexts when they should not introduce a +string token. + + .. _customized-sphinx-lexers: Customized Lexers in Sphinx
