Mercurial > hgrepos > Python > libs > pygments-lexer-pseudocode2
diff docs/lexer-algpseudocode.rst @ 288:298841bc4dee
Allow "normal" Pygments token names in "\ttX" ("Error", "Text.Whitespace", ...)
| author | Franz Glasner <fzglas.hg@dom66.de> |
|---|---|
| date | Fri, 22 May 2026 12:32:38 +0200 |
| parents | 051c8877ee22 |
| children | 6fc7f9c1d89d |
line wrap: on
line diff
--- a/docs/lexer-algpseudocode.rst Fri May 22 12:31:09 2026 +0200 +++ b/docs/lexer-algpseudocode.rst Fri May 22 12:32:38 2026 +0200 @@ -484,10 +484,17 @@ This command has two required parameters: -#. The content of the first argument `ARG1` must be a `value` in the - :py:data:`pygments.token.STANDARD_TYPES` dict. - Its corresponding token type (the associated `key` in this dictionary) - will be used as token type for the token. +#. The content of the first argument `ARG1` can be one of + + - A `value` in the :py:data:`pygments.token.STANDARD_TYPES` dict. + + Its corresponding token type (the associated `key` in this + dictionary) will be used as token type for the token. + + - A string representation of an existing token type without the + ``Token.`` prefix + (e.g. ``String``, ``Generic``, ``Generic.EmphStrong``, ``Text``, + ``Text.Multiline``). If a corresponding token type is not found the lexer's behaviour depends on the lexer option ``strict_tokentype`` (see `Lexer Options`_): @@ -498,9 +505,10 @@ If ``False`` then the `Pygments`_ function :py:func:`pygments.token.string_to_tokentype` will be called. - This function yields either an existing token type or synthesizes + This function returns either an existing token type or synthesizes a new one on the fly. - The associated highlighting in the output may not be well defined. + The associated highlighting with freshly created token types in the + output may not be well defined. For this argument escaping is neither needed nor supported. @@ -509,12 +517,16 @@ Standard `Escaping Rules`_ apply to this argument! -Examples: +.. rubric:: Examples: .. code-block:: algpseudocode - \text{• \\ttX{kc\}{C\}} \ttX{kc}{C} \rem C as Keyword.Constant - \text{• \\ttX{ow\}{∈\}} \ttX{ow}{∈} \rem ∈ as Operator.Word + \text{• \\ttX{\}{token\}} \ttX{}{token} \rem just a base "Token" + + \text{• \\ttX{kc\}{C\}} \ttX{kc}{C} \rem C as Keyword.Constant + \text{• \\ttX{Keyword.Constant\}{C\}} \ttX{kc}{C} \rem C as Keyword.Constant + \text{• \\ttX{ow\}{∈\}} \ttX{ow}{∈} \rem ∈ as Operator.Word + \text{• \\ttX{Operator.Word\}{∈\}} \ttX{ow}{∈} \rem ∈ as Operator.Word \text{• \\ttX{kc\}{A Constant Keyword\}} \ttX{kc}{A Constant Keyword} \rem An explicit Keyword.Constant \text{• \\ttX{nv\}{A Variable Name\}} \ttX{nv}{A Variable Name} \rem An explicit Name.Variable \text{• \\ttX{ni\}{An Entity*Name\}} \ttX{ni}{An Entity*Name} \rem An explicit Name.Entity @@ -524,21 +536,24 @@ * The line below has ∈_∌ as (peculiar) function name. * Their params are automatic (i.e. a normal expression). */ - \text{• \\ttX{nf\}{∈_∌\}(p1, p2)} \ttX{nf}{∈_∌}(p1, p2) + \text{• \\ttX{nf\}{∈_∌\}(p1, p2)} \ttX{nf}{∈_∌}(p1, p2) + \text{• \\ttX{Name.Function\}{∈_∌\}(p1, p2)} \ttX{Name.Function}{∈_∌}(p1, p2) /* * The line below has ∈_∌ as (peculiar) decorator name (as used in Python). * Their params are automatic (i.e. a normal expression). */ - \text{• \\ttX{nd\}{∈_∌\}(p1, p2)} \ttX{nd}{∈_∌}(p1, p2) + \text{• \\ttX{nd\}{∈_∌\}(p1, p2)} \ttX{nd}{∈_∌}(p1, p2) + \text{• \\ttX{Name.Decorator\}{∈_∌\}(p1, p2)} \ttX{Name.Decorator}{∈_∌}(p1, p2) /* * Normal emphasis ("strong") */ - \text{• \\ttX{gs\}{this is strong\}} \ttX{gs}{this is strong} + \text{• \\ttX{gs\}{this is strong\}} \ttX{gs}{this is strong} + \text{• \\ttX{Generic.Strong\}{this is strong\}} \ttX{Generic.Strong}{this is strong} /* * A strong emphasis. - * Note that the backslash is a valid delimiter! */ - \text{• \\ttX{ges\}{A Strong Emphasis!\}} \ttX{ges}{A Strong Emphasis!} + \text{• \\ttX{ges\}{A Strong Emphasis!\}} \ttX{ges}{A Strong Emphasis!} + \text{• \\ttX{Generic.EmphStrong\}{A Strong Emphasis!\}} \ttX{Generic.EmphStrong}{A Strong Emphasis!} /* * Escaping is allowed and needed for the closing brace! * The example token type is a "String". @@ -550,15 +565,14 @@ * token and no expansion. * See also `Lexer Options` and `strict_tokentype`. */ - \text{• \\ttX{NON-EXISTING\}{∈_∌\}(p1, p2)} \ttX{NON_EXISTING}{∈_∌}(p1, p2) + \text{• \\ttX{NON-EXISTING\}{∈_∌\}(p1, p2)} \ttX{NON-EXISTING}{∈_∌}(p1, p2) An example with a lexer and ``strict_tokentype=False`` (highlighting obviously is like standard text with the templates used): .. code-block:: nonstrict-algpseudocode - \text{• \\ttX{Generic.Not.Yet.Existing\}{∈_∌\}(p1, p2)} \ttX{Generic.Not.Yet.Existing}{∈_∌}(p1, p2) - + \text{• \\ttX{Generic.Not.Yet.Existing\}{∈_∌\}(p1, p2)} \ttX{Generic.Not.Yet.Existing}{∈_∌}(p1, p2) Old Syntax (Deprecated)
