annotate docs/lexer-algpseudocode.rst @ 294:a094305c5708

Docs. More cross-refs.
author Franz Glasner <fzglas.hg@dom66.de>
date Sat, 23 May 2026 11:43:21 +0200
parents 3e2f7ca64894
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
88
03e9031b5eca Some details and examples about \tt-XXX and \ttx-XXX in the docs
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
1 .. -*- coding: utf-8; indent-tabs-mode: nil; -*-
03e9031b5eca Some details and examples about \tt-XXX and \ttx-XXX in the docs
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
2
294
Franz Glasner <fzglas.hg@dom66.de>
parents: 290
diff changeset
3 .. _lexer-algpseudocode:
88
03e9031b5eca Some details and examples about \tt-XXX and \ttx-XXX in the docs
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
4
168
bff8b900713a REFACTOR: All documentation pages refactored: merge intro and details for lexers and filters
Franz Glasner <fzglas.hg@dom66.de>
parents: 165
diff changeset
5 *************************************
bff8b900713a REFACTOR: All documentation pages refactored: merge intro and details for lexers and filters
Franz Glasner <fzglas.hg@dom66.de>
parents: 165
diff changeset
6 AlgPseudocode and Language Variants
bff8b900713a REFACTOR: All documentation pages refactored: merge intro and details for lexers and filters
Franz Glasner <fzglas.hg@dom66.de>
parents: 165
diff changeset
7 *************************************
bff8b900713a REFACTOR: All documentation pages refactored: merge intro and details for lexers and filters
Franz Glasner <fzglas.hg@dom66.de>
parents: 165
diff changeset
8
263
2e78e255b54e Make a link to the reST source where appropriate to learn about the lexer syntax
Franz Glasner <fzglas.hg@dom66.de>
parents: 241
diff changeset
9 .. only:: html
2e78e255b54e Make a link to the reST source where appropriate to learn about the lexer syntax
Franz Glasner <fzglas.hg@dom66.de>
parents: 241
diff changeset
10
284
1683a10eabb2 FIX: Heading levels
Franz Glasner <fzglas.hg@dom66.de>
parents: 281
diff changeset
11 .. contents::
265
e5ea2f955986 Optimize documentation layout: use a local ToC where appropriate (lexers, filters)
Franz Glasner <fzglas.hg@dom66.de>
parents: 263
diff changeset
12
e5ea2f955986 Optimize documentation layout: use a local ToC where appropriate (lexers, filters)
Franz Glasner <fzglas.hg@dom66.de>
parents: 263
diff changeset
13 .. only:: html
e5ea2f955986 Optimize documentation layout: use a local ToC where appropriate (lexers, filters)
Franz Glasner <fzglas.hg@dom66.de>
parents: 263
diff changeset
14
263
2e78e255b54e Make a link to the reST source where appropriate to learn about the lexer syntax
Franz Glasner <fzglas.hg@dom66.de>
parents: 241
diff changeset
15 .. hint::
2e78e255b54e Make a link to the reST source where appropriate to learn about the lexer syntax
Franz Glasner <fzglas.hg@dom66.de>
parents: 241
diff changeset
16 The reST source of this documentation page can be found
2e78e255b54e Make a link to the reST source where appropriate to learn about the lexer syntax
Franz Glasner <fzglas.hg@dom66.de>
parents: 241
diff changeset
17 `here <_sources/lexer-algpseudocode.rst.txt>`_.
2e78e255b54e Make a link to the reST source where appropriate to learn about the lexer syntax
Franz Glasner <fzglas.hg@dom66.de>
parents: 241
diff changeset
18
192
156bcd310596 FIX: duplicate word
Franz Glasner <fzglas.hg@dom66.de>
parents: 187
diff changeset
19 These lexers are heavily inspired by CTAN’s `Algpseudocodex`_.
201
b6a959c31bed Wording
Franz Glasner <fzglas.hg@dom66.de>
parents: 194
diff changeset
20 They recognize all sorts of single- and multi-line comments in addition to
b6a959c31bed Wording
Franz Glasner <fzglas.hg@dom66.de>
parents: 194
diff changeset
21 expressions and commands that are inspired by `Algpseudocodex`_.
168
bff8b900713a REFACTOR: All documentation pages refactored: merge intro and details for lexers and filters
Franz Glasner <fzglas.hg@dom66.de>
parents: 165
diff changeset
22
266
50bd1e91b822 Doc enhancements: style, sub-headings, wording, examples, details
Franz Glasner <fzglas.hg@dom66.de>
parents: 265
diff changeset
23 They are used in `Sphinx`_ using their aliases.
268
ea19b621081d Consistently write code blocks in the documentation text as "code block".
Franz Glasner <fzglas.hg@dom66.de>
parents: 266
diff changeset
24 The code block:
168
bff8b900713a REFACTOR: All documentation pages refactored: merge intro and details for lexers and filters
Franz Glasner <fzglas.hg@dom66.de>
parents: 165
diff changeset
25
bff8b900713a REFACTOR: All documentation pages refactored: merge intro and details for lexers and filters
Franz Glasner <fzglas.hg@dom66.de>
parents: 165
diff changeset
26 .. code-block:: none
bff8b900713a REFACTOR: All documentation pages refactored: merge intro and details for lexers and filters
Franz Glasner <fzglas.hg@dom66.de>
parents: 165
diff changeset
27
bff8b900713a REFACTOR: All documentation pages refactored: merge intro and details for lexers and filters
Franz Glasner <fzglas.hg@dom66.de>
parents: 165
diff changeset
28 .. code-block:: algpseudocode
bff8b900713a REFACTOR: All documentation pages refactored: merge intro and details for lexers and filters
Franz Glasner <fzglas.hg@dom66.de>
parents: 165
diff changeset
29
bff8b900713a REFACTOR: All documentation pages refactored: merge intro and details for lexers and filters
Franz Glasner <fzglas.hg@dom66.de>
parents: 165
diff changeset
30 \PROGRAM {The Pseudoprogram} \IS
bff8b900713a REFACTOR: All documentation pages refactored: merge intro and details for lexers and filters
Franz Glasner <fzglas.hg@dom66.de>
parents: 165
diff changeset
31
bff8b900713a REFACTOR: All documentation pages refactored: merge intro and details for lexers and filters
Franz Glasner <fzglas.hg@dom66.de>
parents: 165
diff changeset
32 \END PROGRAM {The Pseudoprogram}
bff8b900713a REFACTOR: All documentation pages refactored: merge intro and details for lexers and filters
Franz Glasner <fzglas.hg@dom66.de>
parents: 165
diff changeset
33
186
95754197f5b3 Link to some source code of example pseudocode files
Franz Glasner <fzglas.hg@dom66.de>
parents: 172
diff changeset
34 will be rendered as:
168
bff8b900713a REFACTOR: All documentation pages refactored: merge intro and details for lexers and filters
Franz Glasner <fzglas.hg@dom66.de>
parents: 165
diff changeset
35
bff8b900713a REFACTOR: All documentation pages refactored: merge intro and details for lexers and filters
Franz Glasner <fzglas.hg@dom66.de>
parents: 165
diff changeset
36 .. code-block:: algpseudocode
bff8b900713a REFACTOR: All documentation pages refactored: merge intro and details for lexers and filters
Franz Glasner <fzglas.hg@dom66.de>
parents: 165
diff changeset
37
bff8b900713a REFACTOR: All documentation pages refactored: merge intro and details for lexers and filters
Franz Glasner <fzglas.hg@dom66.de>
parents: 165
diff changeset
38 \PROGRAM {The Pseudoprogram} \IS
bff8b900713a REFACTOR: All documentation pages refactored: merge intro and details for lexers and filters
Franz Glasner <fzglas.hg@dom66.de>
parents: 165
diff changeset
39
bff8b900713a REFACTOR: All documentation pages refactored: merge intro and details for lexers and filters
Franz Glasner <fzglas.hg@dom66.de>
parents: 165
diff changeset
40 \END PROGRAM {The Pseudoprogram}
bff8b900713a REFACTOR: All documentation pages refactored: merge intro and details for lexers and filters
Franz Glasner <fzglas.hg@dom66.de>
parents: 165
diff changeset
41
268
ea19b621081d Consistently write code blocks in the documentation text as "code block".
Franz Glasner <fzglas.hg@dom66.de>
parents: 266
diff changeset
42 And the same code block with the german variant
168
bff8b900713a REFACTOR: All documentation pages refactored: merge intro and details for lexers and filters
Franz Glasner <fzglas.hg@dom66.de>
parents: 165
diff changeset
43 (using ``.. code-block:: algpseudocode-de`` as language alias):
bff8b900713a REFACTOR: All documentation pages refactored: merge intro and details for lexers and filters
Franz Glasner <fzglas.hg@dom66.de>
parents: 165
diff changeset
44
bff8b900713a REFACTOR: All documentation pages refactored: merge intro and details for lexers and filters
Franz Glasner <fzglas.hg@dom66.de>
parents: 165
diff changeset
45 .. code-block:: algpseudocode-de
bff8b900713a REFACTOR: All documentation pages refactored: merge intro and details for lexers and filters
Franz Glasner <fzglas.hg@dom66.de>
parents: 165
diff changeset
46
bff8b900713a REFACTOR: All documentation pages refactored: merge intro and details for lexers and filters
Franz Glasner <fzglas.hg@dom66.de>
parents: 165
diff changeset
47 \PROGRAM {The Pseudoprogram} \IS
bff8b900713a REFACTOR: All documentation pages refactored: merge intro and details for lexers and filters
Franz Glasner <fzglas.hg@dom66.de>
parents: 165
diff changeset
48
bff8b900713a REFACTOR: All documentation pages refactored: merge intro and details for lexers and filters
Franz Glasner <fzglas.hg@dom66.de>
parents: 165
diff changeset
49 \END PROGRAM {The Pseudoprogram}
bff8b900713a REFACTOR: All documentation pages refactored: merge intro and details for lexers and filters
Franz Glasner <fzglas.hg@dom66.de>
parents: 165
diff changeset
50
169
3c517c22df9c Much more details and refinements in the docs
Franz Glasner <fzglas.hg@dom66.de>
parents: 168
diff changeset
51
3c517c22df9c Much more details and refinements in the docs
Franz Glasner <fzglas.hg@dom66.de>
parents: 168
diff changeset
52 States
3c517c22df9c Much more details and refinements in the docs
Franz Glasner <fzglas.hg@dom66.de>
parents: 168
diff changeset
53 ======
3c517c22df9c Much more details and refinements in the docs
Franz Glasner <fzglas.hg@dom66.de>
parents: 168
diff changeset
54
168
bff8b900713a REFACTOR: All documentation pages refactored: merge intro and details for lexers and filters
Franz Glasner <fzglas.hg@dom66.de>
parents: 165
diff changeset
55 The AlgPseudocode lexer and its language variants AlgPseudocodeDE and
208
de7118d299e9 Aliases for states: context or mode
Franz Glasner <fzglas.hg@dom66.de>
parents: 207
diff changeset
56 AlgPseudocodeFR basically work in three states (aka modes or contexts):
de7118d299e9 Aliases for states: context or mode
Franz Glasner <fzglas.hg@dom66.de>
parents: 207
diff changeset
57 `default`, `expression` and `text`.
168
bff8b900713a REFACTOR: All documentation pages refactored: merge intro and details for lexers and filters
Franz Glasner <fzglas.hg@dom66.de>
parents: 165
diff changeset
58
208
de7118d299e9 Aliases for states: context or mode
Franz Glasner <fzglas.hg@dom66.de>
parents: 207
diff changeset
59 In `expressions` it automatically recognizes:
168
bff8b900713a REFACTOR: All documentation pages refactored: merge intro and details for lexers and filters
Franz Glasner <fzglas.hg@dom66.de>
parents: 165
diff changeset
60
bff8b900713a REFACTOR: All documentation pages refactored: merge intro and details for lexers and filters
Franz Glasner <fzglas.hg@dom66.de>
parents: 165
diff changeset
61 - Strings (single-quote, double-quote, triple-single-quote,
bff8b900713a REFACTOR: All documentation pages refactored: merge intro and details for lexers and filters
Franz Glasner <fzglas.hg@dom66.de>
parents: 165
diff changeset
62 triple-double-quote, `Python`_ style)
bff8b900713a REFACTOR: All documentation pages refactored: merge intro and details for lexers and filters
Franz Glasner <fzglas.hg@dom66.de>
parents: 165
diff changeset
63 - Numbers (also `Python`_ style)
bff8b900713a REFACTOR: All documentation pages refactored: merge intro and details for lexers and filters
Franz Glasner <fzglas.hg@dom66.de>
parents: 165
diff changeset
64 - (Mathematical) operators and symbols
281
ee512932d603 Make "\T" and "\E" aliases for "\TEXT" and "\EXPRESSION"
Franz Glasner <fzglas.hg@dom66.de>
parents: 278
diff changeset
65 - ``\TEXT{...}`` or ``\T{...}``
168
bff8b900713a REFACTOR: All documentation pages refactored: merge intro and details for lexers and filters
Franz Glasner <fzglas.hg@dom66.de>
parents: 165
diff changeset
66
266
50bd1e91b822 Doc enhancements: style, sub-headings, wording, examples, details
Franz Glasner <fzglas.hg@dom66.de>
parents: 265
diff changeset
67 Used to switch to a text-mode that prohibits automatic expression
168
bff8b900713a REFACTOR: All documentation pages refactored: merge intro and details for lexers and filters
Franz Glasner <fzglas.hg@dom66.de>
parents: 165
diff changeset
68 highlighting.
bff8b900713a REFACTOR: All documentation pages refactored: merge intro and details for lexers and filters
Franz Glasner <fzglas.hg@dom66.de>
parents: 165
diff changeset
69
bff8b900713a REFACTOR: All documentation pages refactored: merge intro and details for lexers and filters
Franz Glasner <fzglas.hg@dom66.de>
parents: 165
diff changeset
70 A closing curly brace can be quoted with ``\}`` to not end the
bff8b900713a REFACTOR: All documentation pages refactored: merge intro and details for lexers and filters
Franz Glasner <fzglas.hg@dom66.de>
parents: 165
diff changeset
71 text mode prematurely.
bff8b900713a REFACTOR: All documentation pages refactored: merge intro and details for lexers and filters
Franz Glasner <fzglas.hg@dom66.de>
parents: 165
diff changeset
72
281
ee512932d603 Make "\T" and "\E" aliases for "\TEXT" and "\EXPRESSION"
Franz Glasner <fzglas.hg@dom66.de>
parents: 278
diff changeset
73 - ``\EXPR``, ``\EXPRESSION`` or ``\E`` as nested construct
212
18553f595b34 Allow nested \TEXT and \EXPR commands.
Franz Glasner <fzglas.hg@dom66.de>
parents: 209
diff changeset
74
168
bff8b900713a REFACTOR: All documentation pages refactored: merge intro and details for lexers and filters
Franz Glasner <fzglas.hg@dom66.de>
parents: 165
diff changeset
75 - ``\NAME``, ``\CALL`` and ``\GETS``
bff8b900713a REFACTOR: All documentation pages refactored: merge intro and details for lexers and filters
Franz Glasner <fzglas.hg@dom66.de>
parents: 165
diff changeset
76
bff8b900713a REFACTOR: All documentation pages refactored: merge intro and details for lexers and filters
Franz Glasner <fzglas.hg@dom66.de>
parents: 165
diff changeset
77 - ``\REM`` and ``\REMARK`` for remarks (aka comments)
bff8b900713a REFACTOR: All documentation pages refactored: merge intro and details for lexers and filters
Franz Glasner <fzglas.hg@dom66.de>
parents: 165
diff changeset
78
bff8b900713a REFACTOR: All documentation pages refactored: merge intro and details for lexers and filters
Franz Glasner <fzglas.hg@dom66.de>
parents: 165
diff changeset
79 - Names (`Name.Entity`)
bff8b900713a REFACTOR: All documentation pages refactored: merge intro and details for lexers and filters
Franz Glasner <fzglas.hg@dom66.de>
parents: 165
diff changeset
80
bff8b900713a REFACTOR: All documentation pages refactored: merge intro and details for lexers and filters
Franz Glasner <fzglas.hg@dom66.de>
parents: 165
diff changeset
81 - :ref:`explicit-token-types`
bff8b900713a REFACTOR: All documentation pages refactored: merge intro and details for lexers and filters
Franz Glasner <fzglas.hg@dom66.de>
parents: 165
diff changeset
82
266
50bd1e91b822 Doc enhancements: style, sub-headings, wording, examples, details
Franz Glasner <fzglas.hg@dom66.de>
parents: 265
diff changeset
83 The `default`-mode is an extension of `expression`:
50bd1e91b822 Doc enhancements: style, sub-headings, wording, examples, details
Franz Glasner <fzglas.hg@dom66.de>
parents: 265
diff changeset
84 in addition to `expressions` it recognizes all sorts of single- and
50bd1e91b822 Doc enhancements: style, sub-headings, wording, examples, details
Franz Glasner <fzglas.hg@dom66.de>
parents: 265
diff changeset
85 multi-line comments and commands that are inspired by `Algpseudocodex`_.
168
bff8b900713a REFACTOR: All documentation pages refactored: merge intro and details for lexers and filters
Franz Glasner <fzglas.hg@dom66.de>
parents: 165
diff changeset
86
266
50bd1e91b822 Doc enhancements: style, sub-headings, wording, examples, details
Franz Glasner <fzglas.hg@dom66.de>
parents: 265
diff changeset
87 In `text` context it recognizes:
168
bff8b900713a REFACTOR: All documentation pages refactored: merge intro and details for lexers and filters
Franz Glasner <fzglas.hg@dom66.de>
parents: 165
diff changeset
88
281
ee512932d603 Make "\T" and "\E" aliases for "\TEXT" and "\EXPRESSION"
Franz Glasner <fzglas.hg@dom66.de>
parents: 278
diff changeset
89 - ``\EXPRESSION``, ``\EXPR`` or ``\E``
168
bff8b900713a REFACTOR: All documentation pages refactored: merge intro and details for lexers and filters
Franz Glasner <fzglas.hg@dom66.de>
parents: 165
diff changeset
90
266
50bd1e91b822 Doc enhancements: style, sub-headings, wording, examples, details
Franz Glasner <fzglas.hg@dom66.de>
parents: 265
diff changeset
91 Use to switch to expression-mode.
168
bff8b900713a REFACTOR: All documentation pages refactored: merge intro and details for lexers and filters
Franz Glasner <fzglas.hg@dom66.de>
parents: 165
diff changeset
92
bff8b900713a REFACTOR: All documentation pages refactored: merge intro and details for lexers and filters
Franz Glasner <fzglas.hg@dom66.de>
parents: 165
diff changeset
93 A closing curly brace can be quoted with ``\}`` to not end the expression
bff8b900713a REFACTOR: All documentation pages refactored: merge intro and details for lexers and filters
Franz Glasner <fzglas.hg@dom66.de>
parents: 165
diff changeset
94 mode prematurely.
bff8b900713a REFACTOR: All documentation pages refactored: merge intro and details for lexers and filters
Franz Glasner <fzglas.hg@dom66.de>
parents: 165
diff changeset
95
281
ee512932d603 Make "\T" and "\E" aliases for "\TEXT" and "\EXPRESSION"
Franz Glasner <fzglas.hg@dom66.de>
parents: 278
diff changeset
96 - ``\TEXT`` (aka ``\T``) as nested construct
212
18553f595b34 Allow nested \TEXT and \EXPR commands.
Franz Glasner <fzglas.hg@dom66.de>
parents: 209
diff changeset
97
168
bff8b900713a REFACTOR: All documentation pages refactored: merge intro and details for lexers and filters
Franz Glasner <fzglas.hg@dom66.de>
parents: 165
diff changeset
98 - ``\REM`` and ``\REMARK`` for remarks (aka comments)
bff8b900713a REFACTOR: All documentation pages refactored: merge intro and details for lexers and filters
Franz Glasner <fzglas.hg@dom66.de>
parents: 165
diff changeset
99
bff8b900713a REFACTOR: All documentation pages refactored: merge intro and details for lexers and filters
Franz Glasner <fzglas.hg@dom66.de>
parents: 165
diff changeset
100 - :ref:`explicit-token-types`
bff8b900713a REFACTOR: All documentation pages refactored: merge intro and details for lexers and filters
Franz Glasner <fzglas.hg@dom66.de>
parents: 165
diff changeset
101
bff8b900713a REFACTOR: All documentation pages refactored: merge intro and details for lexers and filters
Franz Glasner <fzglas.hg@dom66.de>
parents: 165
diff changeset
102
125
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
103 Lexer Options
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
104 =============
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
105
160
b4028838e0c8 Implement lexer option "prohibit_raiseonerror_filter".
Franz Glasner <fzglas.hg@dom66.de>
parents: 159
diff changeset
106 .. describe:: prohibit_raiseonerror_filter
b4028838e0c8 Implement lexer option "prohibit_raiseonerror_filter".
Franz Glasner <fzglas.hg@dom66.de>
parents: 159
diff changeset
107
165
88f872c50aae Markup of Python objects in docs
Franz Glasner <fzglas.hg@dom66.de>
parents: 164
diff changeset
108 **Type:** :py:class:`bool`
160
b4028838e0c8 Implement lexer option "prohibit_raiseonerror_filter".
Franz Glasner <fzglas.hg@dom66.de>
parents: 159
diff changeset
109
172
ad80fcbf7b47 Docs formatting
Franz Glasner <fzglas.hg@dom66.de>
parents: 169
diff changeset
110 **Default:** :py:obj:`None`
160
b4028838e0c8 Implement lexer option "prohibit_raiseonerror_filter".
Franz Glasner <fzglas.hg@dom66.de>
parents: 159
diff changeset
111
172
ad80fcbf7b47 Docs formatting
Franz Glasner <fzglas.hg@dom66.de>
parents: 169
diff changeset
112 If :py:obj:`True` the `raiseonerror` filter is not allowed to be
ad80fcbf7b47 Docs formatting
Franz Glasner <fzglas.hg@dom66.de>
parents: 169
diff changeset
113 applied by `Sphinx`_ when :py:meth:`Lexer.add_filter` is called.
165
88f872c50aae Markup of Python objects in docs
Franz Glasner <fzglas.hg@dom66.de>
parents: 164
diff changeset
114
160
b4028838e0c8 Implement lexer option "prohibit_raiseonerror_filter".
Franz Glasner <fzglas.hg@dom66.de>
parents: 159
diff changeset
115 This setting does not apply to filters that are set by the standard
b4028838e0c8 Implement lexer option "prohibit_raiseonerror_filter".
Franz Glasner <fzglas.hg@dom66.de>
parents: 159
diff changeset
116 lexer option `filters`.
b4028838e0c8 Implement lexer option "prohibit_raiseonerror_filter".
Franz Glasner <fzglas.hg@dom66.de>
parents: 159
diff changeset
117
142
5df4403f9e18 Reformae the description of the lexer options
Franz Glasner <fzglas.hg@dom66.de>
parents: 127
diff changeset
118 .. describe:: no_end
125
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
119
165
88f872c50aae Markup of Python objects in docs
Franz Glasner <fzglas.hg@dom66.de>
parents: 164
diff changeset
120 **Type:** :py:class:`bool`
142
5df4403f9e18 Reformae the description of the lexer options
Franz Glasner <fzglas.hg@dom66.de>
parents: 127
diff changeset
121
172
ad80fcbf7b47 Docs formatting
Franz Glasner <fzglas.hg@dom66.de>
parents: 169
diff changeset
122 **Default:** :py:obj:`False`
125
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
123
172
ad80fcbf7b47 Docs formatting
Franz Glasner <fzglas.hg@dom66.de>
parents: 169
diff changeset
124 If :py:obj:`True` all the ``\ENDxxx`` commands will be skipped and yield
169
3c517c22df9c Much more details and refinements in the docs
Franz Glasner <fzglas.hg@dom66.de>
parents: 168
diff changeset
125 no output.
125
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
126
286
051c8877ee22 Implement lexer option "strict_tokentype".
Franz Glasner <fzglas.hg@dom66.de>
parents: 285
diff changeset
127 .. describe:: strict_tokentype
051c8877ee22 Implement lexer option "strict_tokentype".
Franz Glasner <fzglas.hg@dom66.de>
parents: 285
diff changeset
128
051c8877ee22 Implement lexer option "strict_tokentype".
Franz Glasner <fzglas.hg@dom66.de>
parents: 285
diff changeset
129 **Type::** :py:class:`bool`
051c8877ee22 Implement lexer option "strict_tokentype".
Franz Glasner <fzglas.hg@dom66.de>
parents: 285
diff changeset
130
051c8877ee22 Implement lexer option "strict_tokentype".
Franz Glasner <fzglas.hg@dom66.de>
parents: 285
diff changeset
131 **Default:** :py:obj:`True`
051c8877ee22 Implement lexer option "strict_tokentype".
Franz Glasner <fzglas.hg@dom66.de>
parents: 285
diff changeset
132
051c8877ee22 Implement lexer option "strict_tokentype".
Franz Glasner <fzglas.hg@dom66.de>
parents: 285
diff changeset
133 Control whether `Explicit Token Types`_ yield
051c8877ee22 Implement lexer option "strict_tokentype".
Franz Glasner <fzglas.hg@dom66.de>
parents: 285
diff changeset
134 :py:class:`pygments.token.Token.Generic.Error` tokens
051c8877ee22 Implement lexer option "strict_tokentype".
Franz Glasner <fzglas.hg@dom66.de>
parents: 285
diff changeset
135 (when ``True``, this is the default)
051c8877ee22 Implement lexer option "strict_tokentype".
Franz Glasner <fzglas.hg@dom66.de>
parents: 285
diff changeset
136 or a token type that is synthesized on the fly by
051c8877ee22 Implement lexer option "strict_tokentype".
Franz Glasner <fzglas.hg@dom66.de>
parents: 285
diff changeset
137 :py:func:`pygments.token.string_to_tokentype`
051c8877ee22 Implement lexer option "strict_tokentype".
Franz Glasner <fzglas.hg@dom66.de>
parents: 285
diff changeset
138 (when ``False``).
051c8877ee22 Implement lexer option "strict_tokentype".
Franz Glasner <fzglas.hg@dom66.de>
parents: 285
diff changeset
139
142
5df4403f9e18 Reformae the description of the lexer options
Franz Glasner <fzglas.hg@dom66.de>
parents: 127
diff changeset
140 .. describe:: gets
125
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
141
165
88f872c50aae Markup of Python objects in docs
Franz Glasner <fzglas.hg@dom66.de>
parents: 164
diff changeset
142 **Type:** :py:class:`str` or :py:obj:`None`
125
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
143
212
18553f595b34 Allow nested \TEXT and \EXPR commands.
Franz Glasner <fzglas.hg@dom66.de>
parents: 209
diff changeset
144 **Default:** :py:obj:`None` (yields ``⟵``)
125
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
145
142
5df4403f9e18 Reformae the description of the lexer options
Franz Glasner <fzglas.hg@dom66.de>
parents: 127
diff changeset
146 The operator symbol to be printed by the command ``\GETS``.
5df4403f9e18 Reformae the description of the lexer options
Franz Glasner <fzglas.hg@dom66.de>
parents: 127
diff changeset
147
5df4403f9e18 Reformae the description of the lexer options
Franz Glasner <fzglas.hg@dom66.de>
parents: 127
diff changeset
148 An often used alternative is ``:=``.
125
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
149
142
5df4403f9e18 Reformae the description of the lexer options
Franz Glasner <fzglas.hg@dom66.de>
parents: 127
diff changeset
150 .. describe:: remark
5df4403f9e18 Reformae the description of the lexer options
Franz Glasner <fzglas.hg@dom66.de>
parents: 127
diff changeset
151
165
88f872c50aae Markup of Python objects in docs
Franz Glasner <fzglas.hg@dom66.de>
parents: 164
diff changeset
152 **Type:** :py:class:`str` or :py:obj:`None`
125
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
153
172
ad80fcbf7b47 Docs formatting
Franz Glasner <fzglas.hg@dom66.de>
parents: 169
diff changeset
154 **Default:** :py:obj:`None` (yields ``▷``)
125
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
155
142
5df4403f9e18 Reformae the description of the lexer options
Franz Glasner <fzglas.hg@dom66.de>
parents: 127
diff changeset
156 The symbol to be printed as when starting comments with
5df4403f9e18 Reformae the description of the lexer options
Franz Glasner <fzglas.hg@dom66.de>
parents: 127
diff changeset
157 ``\REMARK`` or ``\REM``.
125
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
158
144
b616f9645e37 More referencing with internal and external links
Franz Glasner <fzglas.hg@dom66.de>
parents: 142
diff changeset
159 To use a lexer with non-default options in `Sphinx`_ see section
b616f9645e37 More referencing with internal and external links
Franz Glasner <fzglas.hg@dom66.de>
parents: 142
diff changeset
160 :ref:`customized-sphinx-lexers`.
b616f9645e37 More referencing with internal and external links
Franz Glasner <fzglas.hg@dom66.de>
parents: 142
diff changeset
161
125
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
162
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
163 Comments
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
164 ========
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
165
266
50bd1e91b822 Doc enhancements: style, sub-headings, wording, examples, details
Franz Glasner <fzglas.hg@dom66.de>
parents: 265
diff changeset
166 - with the ``\REMARK`` or ``\REM`` keywords
50bd1e91b822 Doc enhancements: style, sub-headings, wording, examples, details
Franz Glasner <fzglas.hg@dom66.de>
parents: 265
diff changeset
167 (until the end of the line; the output includes a leading symbol,
50bd1e91b822 Doc enhancements: style, sub-headings, wording, examples, details
Franz Glasner <fzglas.hg@dom66.de>
parents: 265
diff changeset
168 by default ``▷``)
125
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
169 - multi-line comments with ``/* ... */``; they can be **nested**
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
170 - multi-line comments with ``(* ... *)``; they can be **nested**
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
171 - single-line comments with ``//`` or ``#`` (until the end of the line)
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
172
150
4acf578ae93f Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents: 148
diff changeset
173 .. code-block:: algpseudocode
4acf578ae93f Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents: 148
diff changeset
174
4acf578ae93f Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents: 148
diff changeset
175 /*
4acf578ae93f Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents: 148
diff changeset
176 * A single multiline comment
4acf578ae93f Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents: 148
diff changeset
177 */
4acf578ae93f Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents: 148
diff changeset
178
4acf578ae93f Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents: 148
diff changeset
179 /*
4acf578ae93f Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents: 148
diff changeset
180 * A multiline comment
4acf578ae93f Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents: 148
diff changeset
181 *
4acf578ae93f Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents: 148
diff changeset
182 * /* This is a nested multi-line comment */
4acf578ae93f Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents: 148
diff changeset
183 *
4acf578ae93f Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents: 148
diff changeset
184 */
4acf578ae93f Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents: 148
diff changeset
185
4acf578ae93f Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents: 148
diff changeset
186 (*
4acf578ae93f Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents: 148
diff changeset
187 * A multiline comment
4acf578ae93f Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents: 148
diff changeset
188 *
4acf578ae93f Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents: 148
diff changeset
189 * (* This is a nested multi-line comment *)
4acf578ae93f Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents: 148
diff changeset
190 *
4acf578ae93f Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents: 148
diff changeset
191 *)
4acf578ae93f Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents: 148
diff changeset
192
4acf578ae93f Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents: 148
diff changeset
193 // A single-line comment
4acf578ae93f Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents: 148
diff changeset
194
4acf578ae93f Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents: 148
diff changeset
195 # A single-line comment
4acf578ae93f Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents: 148
diff changeset
196
213
d470250f8451 Title/metadata of PDF documentation builds:
Franz Glasner <fzglas.hg@dom66.de>
parents: 212
diff changeset
197 \REM A remark is a single-line comment with a leading symbol
150
4acf578ae93f Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents: 148
diff changeset
198
125
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
199
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
200 Literals
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
201 ========
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
202
266
50bd1e91b822 Doc enhancements: style, sub-headings, wording, examples, details
Franz Glasner <fzglas.hg@dom66.de>
parents: 265
diff changeset
203 Strings and numbers as in `Python`_.
50bd1e91b822 Doc enhancements: style, sub-headings, wording, examples, details
Franz Glasner <fzglas.hg@dom66.de>
parents: 265
diff changeset
204 String prefixes ``u`` and ``b`` are supported---prefixes
50bd1e91b822 Doc enhancements: style, sub-headings, wording, examples, details
Franz Glasner <fzglas.hg@dom66.de>
parents: 265
diff changeset
205 ``r``, ``f`` and ``t`` are not supported.
125
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
206
266
50bd1e91b822 Doc enhancements: style, sub-headings, wording, examples, details
Franz Glasner <fzglas.hg@dom66.de>
parents: 265
diff changeset
207 To have non-string-delimiting single- and double-quotes in the output you
50bd1e91b822 Doc enhancements: style, sub-headings, wording, examples, details
Franz Glasner <fzglas.hg@dom66.de>
parents: 265
diff changeset
208 have to escape them using ``\'`` or ``\"``.
274
77cfab93a60e FIX: Example when escaping string delimiters
Franz Glasner <fzglas.hg@dom66.de>
parents: 269
diff changeset
209 This must be used to typeset something as :algpseudocode:`f\'(x) = 0`.
125
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
210
150
4acf578ae93f Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents: 148
diff changeset
211 .. code-block:: algpseudocode
4acf578ae93f Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents: 148
diff changeset
212
241
7df1fd3bab87 In the number example use 1234567890 also
Franz Glasner <fzglas.hg@dom66.de>
parents: 237
diff changeset
213 0 1234567890 0xdead 0b100001 0o720 2.7 2.7e-54
150
4acf578ae93f Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents: 148
diff changeset
214
4acf578ae93f Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents: 148
diff changeset
215 "A string with an escaped double-quote \" "
4acf578ae93f Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents: 148
diff changeset
216
4acf578ae93f Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents: 148
diff changeset
217 'Another string with an escaped single-quote \' '
4acf578ae93f Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents: 148
diff changeset
218
4acf578ae93f Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents: 148
diff changeset
219 """A multiline
4acf578ae93f Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents: 148
diff changeset
220 string
4acf578ae93f Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents: 148
diff changeset
221 """
4acf578ae93f Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents: 148
diff changeset
222
4acf578ae93f Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents: 148
diff changeset
223 '''Another multiline string
4acf578ae93f Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents: 148
diff changeset
224
4acf578ae93f Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents: 148
diff changeset
225 '''
4acf578ae93f Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents: 148
diff changeset
226
4acf578ae93f Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents: 148
diff changeset
227 b"A \x20 byte string"
4acf578ae93f Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents: 148
diff changeset
228
4acf578ae93f Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents: 148
diff changeset
229 u'An explicit Unicode \u1234 string'
4acf578ae93f Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents: 148
diff changeset
230
4acf578ae93f Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents: 148
diff changeset
231 \" a non string
4acf578ae93f Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents: 148
diff changeset
232
4acf578ae93f Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents: 148
diff changeset
233 \' a non string also
4acf578ae93f Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents: 148
diff changeset
234
4acf578ae93f Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents: 148
diff changeset
235
4acf578ae93f Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents: 148
diff changeset
236 (Mathematical) Symbols and Operators
4acf578ae93f Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents: 148
diff changeset
237 ====================================
4acf578ae93f Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents: 148
diff changeset
238
4acf578ae93f Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents: 148
diff changeset
239 Some ASCII symbol combinations are recognized and replaced by a
4acf578ae93f Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents: 148
diff changeset
240 Unicode symbol:
4acf578ae93f Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents: 148
diff changeset
241
4acf578ae93f Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents: 148
diff changeset
242 .. code-block:: algpseudocode
4acf578ae93f Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents: 148
diff changeset
243
4acf578ae93f Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents: 148
diff changeset
244 \TEXT{<=>} <=>
4acf578ae93f Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents: 148
diff changeset
245 \TEXT{<->} <->
4acf578ae93f Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents: 148
diff changeset
246 \TEXT{<-} <-
4acf578ae93f Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents: 148
diff changeset
247 \TEXT{->} ->
4acf578ae93f Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents: 148
diff changeset
248 \TEXT{=>} =>
4acf578ae93f Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents: 148
diff changeset
249 \TEXT{<=} <=
4acf578ae93f Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents: 148
diff changeset
250 \TEXT{>=} >=
4acf578ae93f Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents: 148
diff changeset
251 \TEXT{<>} <>
4acf578ae93f Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents: 148
diff changeset
252 \TEXT{!=} !=
4acf578ae93f Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents: 148
diff changeset
253 \TEXT{:=} :=
4acf578ae93f Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents: 148
diff changeset
254 \TEXT{=:} =:
4acf578ae93f Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents: 148
diff changeset
255 \TEXT{?=} ?=
4acf578ae93f Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents: 148
diff changeset
256
277
a5c96fdd1cb3 Wording in docs
Franz Glasner <fzglas.hg@dom66.de>
parents: 276
diff changeset
257 Unicode codepoints with property ``Sm`` are recognized as mathematical symbols
150
4acf578ae93f Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents: 148
diff changeset
258 and highlighted accordingly.
4acf578ae93f Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents: 148
diff changeset
259
125
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
260
159
4ee0b1536ea6 Handle runs of dots in expressions (., .., ..., ...., ...)
Franz Glasner <fzglas.hg@dom66.de>
parents: 158
diff changeset
261 Punctuation
4ee0b1536ea6 Handle runs of dots in expressions (., .., ..., ...., ...)
Franz Glasner <fzglas.hg@dom66.de>
parents: 158
diff changeset
262 ===========
4ee0b1536ea6 Handle runs of dots in expressions (., .., ..., ...., ...)
Franz Glasner <fzglas.hg@dom66.de>
parents: 158
diff changeset
263
4ee0b1536ea6 Handle runs of dots in expressions (., .., ..., ...., ...)
Franz Glasner <fzglas.hg@dom66.de>
parents: 158
diff changeset
264 Runs of dots ``.``, ``..``, ``...``, ``....``, ... are handled
4ee0b1536ea6 Handle runs of dots in expressions (., .., ..., ...., ...)
Franz Glasner <fzglas.hg@dom66.de>
parents: 158
diff changeset
265 properly in expressions and yield a punctuation token.
4ee0b1536ea6 Handle runs of dots in expressions (., .., ..., ...., ...)
Franz Glasner <fzglas.hg@dom66.de>
parents: 158
diff changeset
266 They are not replaced by corresponding Unicode symbols.
4ee0b1536ea6 Handle runs of dots in expressions (., .., ..., ...., ...)
Franz Glasner <fzglas.hg@dom66.de>
parents: 158
diff changeset
267
4ee0b1536ea6 Handle runs of dots in expressions (., .., ..., ...., ...)
Franz Glasner <fzglas.hg@dom66.de>
parents: 158
diff changeset
268
169
3c517c22df9c Much more details and refinements in the docs
Franz Glasner <fzglas.hg@dom66.de>
parents: 168
diff changeset
269 Commands
125
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
270 ========
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
271
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
272 - Start with a backslash character ``\``
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
273 - Case-insensitive
266
50bd1e91b822 Doc enhancements: style, sub-headings, wording, examples, details
Franz Glasner <fzglas.hg@dom66.de>
parents: 265
diff changeset
274 - Yield mostly the :py:class:`pygments.token.Token.Keyword` token type
125
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
275 - Translated if a translation is found
169
3c517c22df9c Much more details and refinements in the docs
Franz Glasner <fzglas.hg@dom66.de>
parents: 168
diff changeset
276 - Depending on the command---may have required or optional parameters
125
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
277
169
3c517c22df9c Much more details and refinements in the docs
Franz Glasner <fzglas.hg@dom66.de>
parents: 168
diff changeset
278 Parameter handling is as follows:
125
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
279
169
3c517c22df9c Much more details and refinements in the docs
Franz Glasner <fzglas.hg@dom66.de>
parents: 168
diff changeset
280 * Parameters are enclosed in curly braces ``{`` and ``}``
3c517c22df9c Much more details and refinements in the docs
Franz Glasner <fzglas.hg@dom66.de>
parents: 168
diff changeset
281 * Escaping within the braces is possible using the backslash ``\`` as
3c517c22df9c Much more details and refinements in the docs
Franz Glasner <fzglas.hg@dom66.de>
parents: 168
diff changeset
282 escape character
3c517c22df9c Much more details and refinements in the docs
Franz Glasner <fzglas.hg@dom66.de>
parents: 168
diff changeset
283 * Parameters are separated from the keyword/command by a (possibly empty) run
3c517c22df9c Much more details and refinements in the docs
Franz Glasner <fzglas.hg@dom66.de>
parents: 168
diff changeset
284 of space or TAB characters.
3c517c22df9c Much more details and refinements in the docs
Franz Glasner <fzglas.hg@dom66.de>
parents: 168
diff changeset
285 This is true for required and optional parameters.
209
f20177032d21 A chapter about escaping rules
Franz Glasner <fzglas.hg@dom66.de>
parents: 208
diff changeset
286 - Unrecognized commands typically result in a
f20177032d21 A chapter about escaping rules
Franz Glasner <fzglas.hg@dom66.de>
parents: 208
diff changeset
287 :py:class:`pygments.token.Token.Error` token.
162
11ce0903ff8b Yield lone backslash characters in expressions that not really escape anything as "Generic.Error" now.
Franz Glasner <fzglas.hg@dom66.de>
parents: 160
diff changeset
288
209
f20177032d21 A chapter about escaping rules
Franz Glasner <fzglas.hg@dom66.de>
parents: 208
diff changeset
289 More on escaping rules you can find in :ref:`this chapter <escaping-rules>`.
162
11ce0903ff8b Yield lone backslash characters in expressions that not really escape anything as "Generic.Error" now.
Franz Glasner <fzglas.hg@dom66.de>
parents: 160
diff changeset
290
125
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
291
169
3c517c22df9c Much more details and refinements in the docs
Franz Glasner <fzglas.hg@dom66.de>
parents: 168
diff changeset
292 Commands With Required Parameters
284
1683a10eabb2 FIX: Heading levels
Franz Glasner <fzglas.hg@dom66.de>
parents: 281
diff changeset
293 ---------------------------------
125
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
294
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
295 .. code-block:: algpseudocode
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
296
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
297 \TEXT{\PROGRAM {A Program\} or \PROG {A Program\}} \PROGRAM {A Program}
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
298 \TEXT{\ALGORITHM{An Algorithm\} or \ALGO{An Algorithm\}} \ALGORITHM{An Algorithm}
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
299 \TEXT{\PROCEDURE{A Procedure\} or \PROC{A Procedure\}} \PROCEDURE{A Procedure}
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
300 \TEXT{\FUNCTION{A Function\} or \FUNC{A Function\} or \FN{A Function\}} \FUNCTION{A Function}
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
301 \TEXT{\CLASS{A Class\}} \CLASS{A Class}
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
302
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
303 \TEXT{\STATEMENT{the expression\} \STATE{the expression\} \BLOCK{the expression\}} \STATEMENT{the expression}
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
304
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
305 \TEXT{expr1: \\EXPRESSION{expression a in b\} expr2: \\EXPR{expression b in a\}} \TEXT{expr1: \EXPRESSION{expression a in b} expr2: \EXPR{expression b in a}}
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
306
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
307 \TEXT{\TEXTSTATEMENT{the text\} \TEXTSTATE{the text\} \TSTATEMENT{the text\} \TSTATE{the text\} \TEXTBLOCK{the text\} \TBLOCK{the text\}} \TEXTSTATEMENT{the text}
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
308
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
309 \TEXT{\INPUT{Input 1\}} \INPUT{Input 1}
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
310 \TEXT{\INPUTS{Input 2\}} \INPUTS{Input 2}
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
311
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
312 \TEXT{\OUTPUT{Output 1\}} \OUTPUT{Output 1}
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
313 \TEXT{\OUTPUTS{Output 2\}} \OUTPUTS{Output 2}
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
314
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
315 \TEXT{\ENSURE{Whatever should be ensured!\}} \ENSURE{Whatever should be ensured!}
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
316
142
5df4403f9e18 Reformae the description of the lexer options
Franz Glasner <fzglas.hg@dom66.de>
parents: 127
diff changeset
317 \TEXT{\REQUIRE{Whatever should be required.\}} \REQUIRE{Whatever should be required.}
125
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
318
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
319 \TEXT{\RETURNS{Return 2\}} \RETURNS{Return 2}
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
320
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
321 \TEXT{\CALL{a function\}(p1, p2)} \CALL{a function}(p1, p2)
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
322
150
4acf578ae93f Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents: 148
diff changeset
323 \TEXT{\NAME{an entity name\}} \NAME{an entity name}
4acf578ae93f Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents: 148
diff changeset
324
290
3e2f7ca64894 More cross-references to "Explicit Token Types" in the docs
Franz Glasner <fzglas.hg@dom66.de>
parents: 289
diff changeset
325 For a special command with two required parameters see `Explicit Token Types`_.
3e2f7ca64894 More cross-references to "Explicit Token Types" in the docs
Franz Glasner <fzglas.hg@dom66.de>
parents: 289
diff changeset
326
125
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
327
169
3c517c22df9c Much more details and refinements in the docs
Franz Glasner <fzglas.hg@dom66.de>
parents: 168
diff changeset
328 Commands With Optional Parameters
284
1683a10eabb2 FIX: Heading levels
Franz Glasner <fzglas.hg@dom66.de>
parents: 281
diff changeset
329 ---------------------------------
125
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
330
169
3c517c22df9c Much more details and refinements in the docs
Franz Glasner <fzglas.hg@dom66.de>
parents: 168
diff changeset
331 Some ``END``-commands have optional parameters:
125
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
332
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
333 .. code-block:: algpseudocode
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
334
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
335 \TEXT{\ENDPROGRAM \ENDPROG} \ENDPROGRAM
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
336 \TEXT{\ENDALGORITHM \ENDALGO} \ENDALGORITHM
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
337 \TEXT{\ENDPROCEDURE \ENDPROC} \ENDPROCEDURE
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
338 \TEXT{\ENDFUNCTION \ENDFUNC \ENDFN} \ENDFUNCTION
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
339 \TEXT{\ENDCLASS} \ENDCLASS
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
340
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
341 They are used like this:
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
342
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
343 .. code-block:: algpseudocode
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
344
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
345 \TEXT{\CLASS{Foo Bar Class\} ... \END CLASS {Foo Bar Class\}} \TEXT{yields} \CLASS{Foo Bar Class} ... \END CLASS {Foo Bar Class}
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
346
169
3c517c22df9c Much more details and refinements in the docs
Franz Glasner <fzglas.hg@dom66.de>
parents: 168
diff changeset
347 \TEXT{\CLASS{Foo Bar Class\} ... \END CLASS} \TEXT{yields} \CLASS{Foo Bar Class} ... \END CLASS
3c517c22df9c Much more details and refinements in the docs
Franz Glasner <fzglas.hg@dom66.de>
parents: 168
diff changeset
348
3c517c22df9c Much more details and refinements in the docs
Franz Glasner <fzglas.hg@dom66.de>
parents: 168
diff changeset
349 .. seealso:: For other syntax variants concerning `END` see also section
3c517c22df9c Much more details and refinements in the docs
Franz Glasner <fzglas.hg@dom66.de>
parents: 168
diff changeset
350 `END-Commands`_.
125
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
351
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
352
169
3c517c22df9c Much more details and refinements in the docs
Franz Glasner <fzglas.hg@dom66.de>
parents: 168
diff changeset
353 Commands Without Parameters
284
1683a10eabb2 FIX: Heading levels
Franz Glasner <fzglas.hg@dom66.de>
parents: 281
diff changeset
354 ---------------------------
125
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
355
169
3c517c22df9c Much more details and refinements in the docs
Franz Glasner <fzglas.hg@dom66.de>
parents: 168
diff changeset
356 "Normal" Commands
284
1683a10eabb2 FIX: Heading levels
Franz Glasner <fzglas.hg@dom66.de>
parents: 281
diff changeset
357 ~~~~~~~~~~~~~~~~~
125
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
358
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
359 .. code-block:: algpseudocode
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
360
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
361 \TEXT{\IF} \IF
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
362 \TEXT{\THEN} \THEN
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
363 \TEXT{\ELSE} \ELSE
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
364 \TEXT{\ELSEIF or \ELSIF or \ELIF} \ELSEIF \text{or} \ELSIF \text{or} \ELIF
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
365 \TEXT{\DO} \DO
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
366 \TEXT{\WHILE} \WHILE
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
367 \TEXT{\FORALL} \FORALL
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
368 \TEXT{\FOR} \FOR
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
369 \TEXT{\FROM} \FROM
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
370 \TEXT{\TO} \TO
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
371 \TEXT{\STEP} \STEP
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
372 \TEXT{\IN} \IN
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
373 \TEXT{\LOOP} \LOOP
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
374 \TEXT{\REPEAT} \REPEAT
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
375 \TEXT{\UNTIL} \UNTIL
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
376
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
377 \TEXT{\RETURN} \RETURN
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
378
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
379 \TEXT{\BEGIN} \BEGIN
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
380 \TEXT{\END} \END
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
381
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
382 \TEXT{\IS} \IS
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
383 \TEXT{\WITH} \WITH
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
384
150
4acf578ae93f Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents: 148
diff changeset
385 \TEXT{\GETS} \GETS
4acf578ae93f Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents: 148
diff changeset
386
4acf578ae93f Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents: 148
diff changeset
387 \TEXT{\\REMARK or \\REM} \REMARK A comment with a leading symbol
125
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
388
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
389 ``\REMARK`` or ``\REM`` is special: all characters to the end of the
150
4acf578ae93f Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents: 148
diff changeset
390 line are taken as comment; curly braces are not needed---in fact:
4acf578ae93f Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents: 148
diff changeset
391 they are interpreted to be part of the comment.
125
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
392
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
393
169
3c517c22df9c Much more details and refinements in the docs
Franz Glasner <fzglas.hg@dom66.de>
parents: 168
diff changeset
394 END-Commands
284
1683a10eabb2 FIX: Heading levels
Franz Glasner <fzglas.hg@dom66.de>
parents: 281
diff changeset
395 ~~~~~~~~~~~~
125
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
396
169
3c517c22df9c Much more details and refinements in the docs
Franz Glasner <fzglas.hg@dom66.de>
parents: 168
diff changeset
397 The separator character can be empty, a run of ASCII spaces, a run of
266
50bd1e91b822 Doc enhancements: style, sub-headings, wording, examples, details
Franz Glasner <fzglas.hg@dom66.de>
parents: 265
diff changeset
398 TAB characters, a single underscore ``_`` or a single hyphen ``-``.
50bd1e91b822 Doc enhancements: style, sub-headings, wording, examples, details
Franz Glasner <fzglas.hg@dom66.de>
parents: 265
diff changeset
399
50bd1e91b822 Doc enhancements: style, sub-headings, wording, examples, details
Franz Glasner <fzglas.hg@dom66.de>
parents: 265
diff changeset
400 All of the following examples are equally valid and result in the
50bd1e91b822 Doc enhancements: style, sub-headings, wording, examples, details
Franz Glasner <fzglas.hg@dom66.de>
parents: 265
diff changeset
401 same output:
125
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
402
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
403 ``\ENDIF``, ``\END IF``, ``\END-IF``, ``\END_IF`` or ``\END IF``
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
404
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
405
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
406 .. code-block:: algpseudocode
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
407
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
408 \text{\ENDIF} \ENDIF \rem empty
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
409
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
410 \text{\END IF} \END IF \rem a single space
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
411
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
412 \text{\END IF} \END IF \rem two spaces
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
413
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
414 \text{\END-IF} \END-IF \rem a single hyphen
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
415
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
416 \text{\END_IF} \END_IF \rem a single underscore
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
417
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
418 \text{\END IF} \END IF \rem a single TAB character
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
419
169
3c517c22df9c Much more details and refinements in the docs
Franz Glasner <fzglas.hg@dom66.de>
parents: 168
diff changeset
420 The list of END-commands (here always just with ``-`` as separator):
125
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
421
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
422 .. code-block:: algpseudocode
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
423
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
424 \text{\END-PROGRAM \END-PROG} \END-PROGRAM
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
425 \text{\END-ALGORITHM \END-ALGO} \END-ALGORITHM
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
426 \text{\END-PROCEDURE \END-PROC} \END-PROCEDURE
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
427 \text{\END-FUNCTION \END-FUNC \END-FN} \END-FUNCTION
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
428 \text{\END-CLASS} \END-CLASS
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
429 \text{\END-IF} \END-IF
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
430 \text{\END-WHILE} \END-WHILE
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
431 \text{\END-FOR} \END-FOR
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
432 \text{\END-FORALL} \END-FORALL
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
433 \text{\END-LOOP} \END-LOOP
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
434
266
50bd1e91b822 Doc enhancements: style, sub-headings, wording, examples, details
Franz Glasner <fzglas.hg@dom66.de>
parents: 265
diff changeset
435 .. note:: The output of these END-commands can be suppressed by setting the
172
ad80fcbf7b47 Docs formatting
Franz Glasner <fzglas.hg@dom66.de>
parents: 169
diff changeset
436 lexer option ``no_end`` to :py:obj:`True`.
169
3c517c22df9c Much more details and refinements in the docs
Franz Glasner <fzglas.hg@dom66.de>
parents: 168
diff changeset
437
88
03e9031b5eca Some details and examples about \tt-XXX and \ttx-XXX in the docs
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
438
150
4acf578ae93f Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents: 148
diff changeset
439 Names and Entities
4acf578ae93f Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents: 148
diff changeset
440 ==================
4acf578ae93f Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents: 148
diff changeset
441
277
a5c96fdd1cb3 Wording in docs
Franz Glasner <fzglas.hg@dom66.de>
parents: 276
diff changeset
442 In an `expression` context all other words are interpreted as entity
156
123aeb2de8aa Explicitely call all markup with the domain
Franz Glasner <fzglas.hg@dom66.de>
parents: 154
diff changeset
443 names (token type :py:class:`pygments.token.Token.Name.Entity`).
150
4acf578ae93f Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents: 148
diff changeset
444
4acf578ae93f Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents: 148
diff changeset
445 Allowed characters in the words follow the corresponding `Python`_ rules.
4acf578ae93f Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents: 148
diff changeset
446 As such, many Unicode characters are allowed.
4acf578ae93f Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents: 148
diff changeset
447
4acf578ae93f Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents: 148
diff changeset
448 To highlight entity names with whitespace or other "special" characters in it
4acf578ae93f Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents: 148
diff changeset
449 use the ``NAME`` command.
4acf578ae93f Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents: 148
diff changeset
450
4acf578ae93f Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents: 148
diff changeset
451 .. code-block:: algpseudocode
4acf578ae93f Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents: 148
diff changeset
452
4acf578ae93f Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents: 148
diff changeset
453 \TEXT{entity_name_1} entity_name_1
4acf578ae93f Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents: 148
diff changeset
454
4acf578ae93f Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents: 148
diff changeset
455 \TEXT{entity_name_2} entity_name_2
4acf578ae93f Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents: 148
diff changeset
456
4acf578ae93f Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents: 148
diff changeset
457 \TEXT{\NAME{entity-name 3\}} \NAME{entity-name 3}
4acf578ae93f Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents: 148
diff changeset
458
4acf578ae93f Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents: 148
diff changeset
459 \TEXT{München} München
4acf578ae93f Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents: 148
diff changeset
460
4acf578ae93f Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents: 148
diff changeset
461 \TEXT{Genève} Genève
4acf578ae93f Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents: 148
diff changeset
462
278
315e94bac8a7 Link from "Names and Entities" to "TokenReplaceFilter"
Franz Glasner <fzglas.hg@dom66.de>
parents: 277
diff changeset
463 .. note:: Should you want to change the token type and the associated
315e94bac8a7 Link from "Names and Entities" to "TokenReplaceFilter"
Franz Glasner <fzglas.hg@dom66.de>
parents: 277
diff changeset
464 highlighting you may want to have a look at
315e94bac8a7 Link from "Names and Entities" to "TokenReplaceFilter"
Franz Glasner <fzglas.hg@dom66.de>
parents: 277
diff changeset
465 :ref:`tokenreplacefilter`.
315e94bac8a7 Link from "Names and Entities" to "TokenReplaceFilter"
Franz Glasner <fzglas.hg@dom66.de>
parents: 277
diff changeset
466
169
3c517c22df9c Much more details and refinements in the docs
Franz Glasner <fzglas.hg@dom66.de>
parents: 168
diff changeset
467
150
4acf578ae93f Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents: 148
diff changeset
468 .. _explicit-token-types:
4acf578ae93f Much more details in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents: 148
diff changeset
469
88
03e9031b5eca Some details and examples about \tt-XXX and \ttx-XXX in the docs
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
470 Explicit Token Types
03e9031b5eca Some details and examples about \tt-XXX and \ttx-XXX in the docs
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
471 ====================
03e9031b5eca Some details and examples about \tt-XXX and \ttx-XXX in the docs
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
472
266
50bd1e91b822 Doc enhancements: style, sub-headings, wording, examples, details
Franz Glasner <fzglas.hg@dom66.de>
parents: 265
diff changeset
473 They allow to handle keywords and operators that are not recognized by default.
289
6fc7f9c1d89d Remove the old implementation of explicit token types completely
Franz Glasner <fzglas.hg@dom66.de>
parents: 288
diff changeset
474 And they allow the user to explicitely highlight some input text with
6fc7f9c1d89d Remove the old implementation of explicit token types completely
Franz Glasner <fzglas.hg@dom66.de>
parents: 288
diff changeset
475 a low-level command.
285
afbca50b7dc1 Implement an alternate syntax for "Explicit Token Types".
Franz Glasner <fzglas.hg@dom66.de>
parents: 284
diff changeset
476
289
6fc7f9c1d89d Remove the old implementation of explicit token types completely
Franz Glasner <fzglas.hg@dom66.de>
parents: 288
diff changeset
477 They are implemented with the ``\ttX{ARG1}{ARG2}`` command.
285
afbca50b7dc1 Implement an alternate syntax for "Explicit Token Types".
Franz Glasner <fzglas.hg@dom66.de>
parents: 284
diff changeset
478
afbca50b7dc1 Implement an alternate syntax for "Explicit Token Types".
Franz Glasner <fzglas.hg@dom66.de>
parents: 284
diff changeset
479 This command has two required parameters:
afbca50b7dc1 Implement an alternate syntax for "Explicit Token Types".
Franz Glasner <fzglas.hg@dom66.de>
parents: 284
diff changeset
480
288
298841bc4dee Allow "normal" Pygments token names in "\ttX" ("Error", "Text.Whitespace", ...)
Franz Glasner <fzglas.hg@dom66.de>
parents: 286
diff changeset
481 #. The content of the first argument `ARG1` can be one of
298841bc4dee Allow "normal" Pygments token names in "\ttX" ("Error", "Text.Whitespace", ...)
Franz Glasner <fzglas.hg@dom66.de>
parents: 286
diff changeset
482
298841bc4dee Allow "normal" Pygments token names in "\ttX" ("Error", "Text.Whitespace", ...)
Franz Glasner <fzglas.hg@dom66.de>
parents: 286
diff changeset
483 - A `value` in the :py:data:`pygments.token.STANDARD_TYPES` dict.
298841bc4dee Allow "normal" Pygments token names in "\ttX" ("Error", "Text.Whitespace", ...)
Franz Glasner <fzglas.hg@dom66.de>
parents: 286
diff changeset
484
298841bc4dee Allow "normal" Pygments token names in "\ttX" ("Error", "Text.Whitespace", ...)
Franz Glasner <fzglas.hg@dom66.de>
parents: 286
diff changeset
485 Its corresponding token type (the associated `key` in this
298841bc4dee Allow "normal" Pygments token names in "\ttX" ("Error", "Text.Whitespace", ...)
Franz Glasner <fzglas.hg@dom66.de>
parents: 286
diff changeset
486 dictionary) will be used as token type for the token.
298841bc4dee Allow "normal" Pygments token names in "\ttX" ("Error", "Text.Whitespace", ...)
Franz Glasner <fzglas.hg@dom66.de>
parents: 286
diff changeset
487
298841bc4dee Allow "normal" Pygments token names in "\ttX" ("Error", "Text.Whitespace", ...)
Franz Glasner <fzglas.hg@dom66.de>
parents: 286
diff changeset
488 - A string representation of an existing token type without the
298841bc4dee Allow "normal" Pygments token names in "\ttX" ("Error", "Text.Whitespace", ...)
Franz Glasner <fzglas.hg@dom66.de>
parents: 286
diff changeset
489 ``Token.`` prefix
298841bc4dee Allow "normal" Pygments token names in "\ttX" ("Error", "Text.Whitespace", ...)
Franz Glasner <fzglas.hg@dom66.de>
parents: 286
diff changeset
490 (e.g. ``String``, ``Generic``, ``Generic.EmphStrong``, ``Text``,
298841bc4dee Allow "normal" Pygments token names in "\ttX" ("Error", "Text.Whitespace", ...)
Franz Glasner <fzglas.hg@dom66.de>
parents: 286
diff changeset
491 ``Text.Multiline``).
285
afbca50b7dc1 Implement an alternate syntax for "Explicit Token Types".
Franz Glasner <fzglas.hg@dom66.de>
parents: 284
diff changeset
492
286
051c8877ee22 Implement lexer option "strict_tokentype".
Franz Glasner <fzglas.hg@dom66.de>
parents: 285
diff changeset
493 If a corresponding token type is not found the lexer's behaviour depends
051c8877ee22 Implement lexer option "strict_tokentype".
Franz Glasner <fzglas.hg@dom66.de>
parents: 285
diff changeset
494 on the lexer option ``strict_tokentype`` (see `Lexer Options`_):
051c8877ee22 Implement lexer option "strict_tokentype".
Franz Glasner <fzglas.hg@dom66.de>
parents: 285
diff changeset
495
051c8877ee22 Implement lexer option "strict_tokentype".
Franz Glasner <fzglas.hg@dom66.de>
parents: 285
diff changeset
496 If ``True`` (the default) the command yields a
051c8877ee22 Implement lexer option "strict_tokentype".
Franz Glasner <fzglas.hg@dom66.de>
parents: 285
diff changeset
497 :py:class:`pygments.token.Token.Generic.Error` token type for the
051c8877ee22 Implement lexer option "strict_tokentype".
Franz Glasner <fzglas.hg@dom66.de>
parents: 285
diff changeset
498 given command's content.
051c8877ee22 Implement lexer option "strict_tokentype".
Franz Glasner <fzglas.hg@dom66.de>
parents: 285
diff changeset
499
051c8877ee22 Implement lexer option "strict_tokentype".
Franz Glasner <fzglas.hg@dom66.de>
parents: 285
diff changeset
500 If ``False`` then the `Pygments`_ function
051c8877ee22 Implement lexer option "strict_tokentype".
Franz Glasner <fzglas.hg@dom66.de>
parents: 285
diff changeset
501 :py:func:`pygments.token.string_to_tokentype` will be called.
288
298841bc4dee Allow "normal" Pygments token names in "\ttX" ("Error", "Text.Whitespace", ...)
Franz Glasner <fzglas.hg@dom66.de>
parents: 286
diff changeset
502 This function returns either an existing token type or synthesizes
286
051c8877ee22 Implement lexer option "strict_tokentype".
Franz Glasner <fzglas.hg@dom66.de>
parents: 285
diff changeset
503 a new one on the fly.
288
298841bc4dee Allow "normal" Pygments token names in "\ttX" ("Error", "Text.Whitespace", ...)
Franz Glasner <fzglas.hg@dom66.de>
parents: 286
diff changeset
504 The associated highlighting with freshly created token types in the
298841bc4dee Allow "normal" Pygments token names in "\ttX" ("Error", "Text.Whitespace", ...)
Franz Glasner <fzglas.hg@dom66.de>
parents: 286
diff changeset
505 output may not be well defined.
286
051c8877ee22 Implement lexer option "strict_tokentype".
Franz Glasner <fzglas.hg@dom66.de>
parents: 285
diff changeset
506
051c8877ee22 Implement lexer option "strict_tokentype".
Franz Glasner <fzglas.hg@dom66.de>
parents: 285
diff changeset
507 For this argument escaping is neither needed nor supported.
051c8877ee22 Implement lexer option "strict_tokentype".
Franz Glasner <fzglas.hg@dom66.de>
parents: 285
diff changeset
508
285
afbca50b7dc1 Implement an alternate syntax for "Explicit Token Types".
Franz Glasner <fzglas.hg@dom66.de>
parents: 284
diff changeset
509 #. The content of the second argument will given the token type of
afbca50b7dc1 Implement an alternate syntax for "Explicit Token Types".
Franz Glasner <fzglas.hg@dom66.de>
parents: 284
diff changeset
510 the first parameter.
afbca50b7dc1 Implement an alternate syntax for "Explicit Token Types".
Franz Glasner <fzglas.hg@dom66.de>
parents: 284
diff changeset
511
afbca50b7dc1 Implement an alternate syntax for "Explicit Token Types".
Franz Glasner <fzglas.hg@dom66.de>
parents: 284
diff changeset
512 Standard `Escaping Rules`_ apply to this argument!
afbca50b7dc1 Implement an alternate syntax for "Explicit Token Types".
Franz Glasner <fzglas.hg@dom66.de>
parents: 284
diff changeset
513
289
6fc7f9c1d89d Remove the old implementation of explicit token types completely
Franz Glasner <fzglas.hg@dom66.de>
parents: 288
diff changeset
514 .. note:: The command for explicit token types is **case-sensitive**.
6fc7f9c1d89d Remove the old implementation of explicit token types completely
Franz Glasner <fzglas.hg@dom66.de>
parents: 288
diff changeset
515
288
298841bc4dee Allow "normal" Pygments token names in "\ttX" ("Error", "Text.Whitespace", ...)
Franz Glasner <fzglas.hg@dom66.de>
parents: 286
diff changeset
516 .. rubric:: Examples:
285
afbca50b7dc1 Implement an alternate syntax for "Explicit Token Types".
Franz Glasner <fzglas.hg@dom66.de>
parents: 284
diff changeset
517
afbca50b7dc1 Implement an alternate syntax for "Explicit Token Types".
Franz Glasner <fzglas.hg@dom66.de>
parents: 284
diff changeset
518 .. code-block:: algpseudocode
afbca50b7dc1 Implement an alternate syntax for "Explicit Token Types".
Franz Glasner <fzglas.hg@dom66.de>
parents: 284
diff changeset
519
288
298841bc4dee Allow "normal" Pygments token names in "\ttX" ("Error", "Text.Whitespace", ...)
Franz Glasner <fzglas.hg@dom66.de>
parents: 286
diff changeset
520 \text{• \\ttX{\}{token\}} \ttX{}{token} \rem just a base "Token"
298841bc4dee Allow "normal" Pygments token names in "\ttX" ("Error", "Text.Whitespace", ...)
Franz Glasner <fzglas.hg@dom66.de>
parents: 286
diff changeset
521
298841bc4dee Allow "normal" Pygments token names in "\ttX" ("Error", "Text.Whitespace", ...)
Franz Glasner <fzglas.hg@dom66.de>
parents: 286
diff changeset
522 \text{• \\ttX{kc\}{C\}} \ttX{kc}{C} \rem C as Keyword.Constant
298841bc4dee Allow "normal" Pygments token names in "\ttX" ("Error", "Text.Whitespace", ...)
Franz Glasner <fzglas.hg@dom66.de>
parents: 286
diff changeset
523 \text{• \\ttX{Keyword.Constant\}{C\}} \ttX{kc}{C} \rem C as Keyword.Constant
298841bc4dee Allow "normal" Pygments token names in "\ttX" ("Error", "Text.Whitespace", ...)
Franz Glasner <fzglas.hg@dom66.de>
parents: 286
diff changeset
524 \text{• \\ttX{ow\}{∈\}} \ttX{ow}{∈} \rem ∈ as Operator.Word
298841bc4dee Allow "normal" Pygments token names in "\ttX" ("Error", "Text.Whitespace", ...)
Franz Glasner <fzglas.hg@dom66.de>
parents: 286
diff changeset
525 \text{• \\ttX{Operator.Word\}{∈\}} \ttX{ow}{∈} \rem ∈ as Operator.Word
285
afbca50b7dc1 Implement an alternate syntax for "Explicit Token Types".
Franz Glasner <fzglas.hg@dom66.de>
parents: 284
diff changeset
526 \text{• \\ttX{kc\}{A Constant Keyword\}} \ttX{kc}{A Constant Keyword} \rem An explicit Keyword.Constant
afbca50b7dc1 Implement an alternate syntax for "Explicit Token Types".
Franz Glasner <fzglas.hg@dom66.de>
parents: 284
diff changeset
527 \text{• \\ttX{nv\}{A Variable Name\}} \ttX{nv}{A Variable Name} \rem An explicit Name.Variable
afbca50b7dc1 Implement an alternate syntax for "Explicit Token Types".
Franz Glasner <fzglas.hg@dom66.de>
parents: 284
diff changeset
528 \text{• \\ttX{ni\}{An Entity*Name\}} \ttX{ni}{An Entity*Name} \rem An explicit Name.Entity
afbca50b7dc1 Implement an alternate syntax for "Explicit Token Types".
Franz Glasner <fzglas.hg@dom66.de>
parents: 284
diff changeset
529 \text{• \\ttX{k\}{∈ ∌\}} \ttX{k}{∈ ∌} \rem ∈ and ∌ as (ordinary) Keywords
afbca50b7dc1 Implement an alternate syntax for "Explicit Token Types".
Franz Glasner <fzglas.hg@dom66.de>
parents: 284
diff changeset
530 \text{• \\ttX{o\}{∈ ∌\}} \ttX{o}{∈ ∌} \rem ∈ and ∌ as (ordinary) Operators
afbca50b7dc1 Implement an alternate syntax for "Explicit Token Types".
Franz Glasner <fzglas.hg@dom66.de>
parents: 284
diff changeset
531 /*
afbca50b7dc1 Implement an alternate syntax for "Explicit Token Types".
Franz Glasner <fzglas.hg@dom66.de>
parents: 284
diff changeset
532 * The line below has ∈_∌ as (peculiar) function name.
afbca50b7dc1 Implement an alternate syntax for "Explicit Token Types".
Franz Glasner <fzglas.hg@dom66.de>
parents: 284
diff changeset
533 * Their params are automatic (i.e. a normal expression).
afbca50b7dc1 Implement an alternate syntax for "Explicit Token Types".
Franz Glasner <fzglas.hg@dom66.de>
parents: 284
diff changeset
534 */
288
298841bc4dee Allow "normal" Pygments token names in "\ttX" ("Error", "Text.Whitespace", ...)
Franz Glasner <fzglas.hg@dom66.de>
parents: 286
diff changeset
535 \text{• \\ttX{nf\}{∈_∌\}(p1, p2)} \ttX{nf}{∈_∌}(p1, p2)
298841bc4dee Allow "normal" Pygments token names in "\ttX" ("Error", "Text.Whitespace", ...)
Franz Glasner <fzglas.hg@dom66.de>
parents: 286
diff changeset
536 \text{• \\ttX{Name.Function\}{∈_∌\}(p1, p2)} \ttX{Name.Function}{∈_∌}(p1, p2)
285
afbca50b7dc1 Implement an alternate syntax for "Explicit Token Types".
Franz Glasner <fzglas.hg@dom66.de>
parents: 284
diff changeset
537 /*
afbca50b7dc1 Implement an alternate syntax for "Explicit Token Types".
Franz Glasner <fzglas.hg@dom66.de>
parents: 284
diff changeset
538 * The line below has ∈_∌ as (peculiar) decorator name (as used in Python).
afbca50b7dc1 Implement an alternate syntax for "Explicit Token Types".
Franz Glasner <fzglas.hg@dom66.de>
parents: 284
diff changeset
539 * Their params are automatic (i.e. a normal expression).
afbca50b7dc1 Implement an alternate syntax for "Explicit Token Types".
Franz Glasner <fzglas.hg@dom66.de>
parents: 284
diff changeset
540 */
288
298841bc4dee Allow "normal" Pygments token names in "\ttX" ("Error", "Text.Whitespace", ...)
Franz Glasner <fzglas.hg@dom66.de>
parents: 286
diff changeset
541 \text{• \\ttX{nd\}{∈_∌\}(p1, p2)} \ttX{nd}{∈_∌}(p1, p2)
298841bc4dee Allow "normal" Pygments token names in "\ttX" ("Error", "Text.Whitespace", ...)
Franz Glasner <fzglas.hg@dom66.de>
parents: 286
diff changeset
542 \text{• \\ttX{Name.Decorator\}{∈_∌\}(p1, p2)} \ttX{Name.Decorator}{∈_∌}(p1, p2)
285
afbca50b7dc1 Implement an alternate syntax for "Explicit Token Types".
Franz Glasner <fzglas.hg@dom66.de>
parents: 284
diff changeset
543 /*
afbca50b7dc1 Implement an alternate syntax for "Explicit Token Types".
Franz Glasner <fzglas.hg@dom66.de>
parents: 284
diff changeset
544 * Normal emphasis ("strong")
afbca50b7dc1 Implement an alternate syntax for "Explicit Token Types".
Franz Glasner <fzglas.hg@dom66.de>
parents: 284
diff changeset
545 */
288
298841bc4dee Allow "normal" Pygments token names in "\ttX" ("Error", "Text.Whitespace", ...)
Franz Glasner <fzglas.hg@dom66.de>
parents: 286
diff changeset
546 \text{• \\ttX{gs\}{this is strong\}} \ttX{gs}{this is strong}
298841bc4dee Allow "normal" Pygments token names in "\ttX" ("Error", "Text.Whitespace", ...)
Franz Glasner <fzglas.hg@dom66.de>
parents: 286
diff changeset
547 \text{• \\ttX{Generic.Strong\}{this is strong\}} \ttX{Generic.Strong}{this is strong}
285
afbca50b7dc1 Implement an alternate syntax for "Explicit Token Types".
Franz Glasner <fzglas.hg@dom66.de>
parents: 284
diff changeset
548 /*
afbca50b7dc1 Implement an alternate syntax for "Explicit Token Types".
Franz Glasner <fzglas.hg@dom66.de>
parents: 284
diff changeset
549 * A strong emphasis.
afbca50b7dc1 Implement an alternate syntax for "Explicit Token Types".
Franz Glasner <fzglas.hg@dom66.de>
parents: 284
diff changeset
550 */
288
298841bc4dee Allow "normal" Pygments token names in "\ttX" ("Error", "Text.Whitespace", ...)
Franz Glasner <fzglas.hg@dom66.de>
parents: 286
diff changeset
551 \text{• \\ttX{ges\}{A Strong Emphasis!\}} \ttX{ges}{A Strong Emphasis!}
298841bc4dee Allow "normal" Pygments token names in "\ttX" ("Error", "Text.Whitespace", ...)
Franz Glasner <fzglas.hg@dom66.de>
parents: 286
diff changeset
552 \text{• \\ttX{Generic.EmphStrong\}{A Strong Emphasis!\}} \ttX{Generic.EmphStrong}{A Strong Emphasis!}
285
afbca50b7dc1 Implement an alternate syntax for "Explicit Token Types".
Franz Glasner <fzglas.hg@dom66.de>
parents: 284
diff changeset
553 /*
afbca50b7dc1 Implement an alternate syntax for "Explicit Token Types".
Franz Glasner <fzglas.hg@dom66.de>
parents: 284
diff changeset
554 * Escaping is allowed and needed for the closing brace!
afbca50b7dc1 Implement an alternate syntax for "Explicit Token Types".
Franz Glasner <fzglas.hg@dom66.de>
parents: 284
diff changeset
555 * The example token type is a "String".
afbca50b7dc1 Implement an alternate syntax for "Explicit Token Types".
Franz Glasner <fzglas.hg@dom66.de>
parents: 284
diff changeset
556 */
afbca50b7dc1 Implement an alternate syntax for "Explicit Token Types".
Franz Glasner <fzglas.hg@dom66.de>
parents: 284
diff changeset
557 \text{• \\ttX{s\}{Escaping brace \\\} and backslash \\\\!\}} \ttX{s}{Escaping brace \} and backslash \\!}
afbca50b7dc1 Implement an alternate syntax for "Explicit Token Types".
Franz Glasner <fzglas.hg@dom66.de>
parents: 284
diff changeset
558 /*
286
051c8877ee22 Implement lexer option "strict_tokentype".
Franz Glasner <fzglas.hg@dom66.de>
parents: 285
diff changeset
559 * This is a non-existing token type:
051c8877ee22 Implement lexer option "strict_tokentype".
Franz Glasner <fzglas.hg@dom66.de>
parents: 285
diff changeset
560 * by default you get some generic error markup with a Generic.Error
051c8877ee22 Implement lexer option "strict_tokentype".
Franz Glasner <fzglas.hg@dom66.de>
parents: 285
diff changeset
561 * token and no expansion.
051c8877ee22 Implement lexer option "strict_tokentype".
Franz Glasner <fzglas.hg@dom66.de>
parents: 285
diff changeset
562 * See also `Lexer Options` and `strict_tokentype`.
285
afbca50b7dc1 Implement an alternate syntax for "Explicit Token Types".
Franz Glasner <fzglas.hg@dom66.de>
parents: 284
diff changeset
563 */
288
298841bc4dee Allow "normal" Pygments token names in "\ttX" ("Error", "Text.Whitespace", ...)
Franz Glasner <fzglas.hg@dom66.de>
parents: 286
diff changeset
564 \text{• \\ttX{NON-EXISTING\}{∈_∌\}(p1, p2)} \ttX{NON-EXISTING}{∈_∌}(p1, p2)
285
afbca50b7dc1 Implement an alternate syntax for "Explicit Token Types".
Franz Glasner <fzglas.hg@dom66.de>
parents: 284
diff changeset
565
286
051c8877ee22 Implement lexer option "strict_tokentype".
Franz Glasner <fzglas.hg@dom66.de>
parents: 285
diff changeset
566 An example with a lexer and ``strict_tokentype=False``
051c8877ee22 Implement lexer option "strict_tokentype".
Franz Glasner <fzglas.hg@dom66.de>
parents: 285
diff changeset
567 (highlighting obviously is like standard text with the templates used):
051c8877ee22 Implement lexer option "strict_tokentype".
Franz Glasner <fzglas.hg@dom66.de>
parents: 285
diff changeset
568
051c8877ee22 Implement lexer option "strict_tokentype".
Franz Glasner <fzglas.hg@dom66.de>
parents: 285
diff changeset
569 .. code-block:: nonstrict-algpseudocode
051c8877ee22 Implement lexer option "strict_tokentype".
Franz Glasner <fzglas.hg@dom66.de>
parents: 285
diff changeset
570
288
298841bc4dee Allow "normal" Pygments token names in "\ttX" ("Error", "Text.Whitespace", ...)
Franz Glasner <fzglas.hg@dom66.de>
parents: 286
diff changeset
571 \text{• \\ttX{Generic.Not.Yet.Existing\}{∈_∌\}(p1, p2)} \ttX{Generic.Not.Yet.Existing}{∈_∌}(p1, p2)
285
afbca50b7dc1 Implement an alternate syntax for "Explicit Token Types".
Franz Glasner <fzglas.hg@dom66.de>
parents: 284
diff changeset
572
289
6fc7f9c1d89d Remove the old implementation of explicit token types completely
Franz Glasner <fzglas.hg@dom66.de>
parents: 288
diff changeset
573 .. note:: Explicit token types work in all `expression` and `text` contexts.
88
03e9031b5eca Some details and examples about \tt-XXX and \ttx-XXX in the docs
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff changeset
574
290
3e2f7ca64894 More cross-references to "Explicit Token Types" in the docs
Franz Glasner <fzglas.hg@dom66.de>
parents: 289
diff changeset
575 .. note:: Nesting of explicit token types is *not supported*.
125
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
576
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
577
209
f20177032d21 A chapter about escaping rules
Franz Glasner <fzglas.hg@dom66.de>
parents: 208
diff changeset
578 .. _escaping-rules:
f20177032d21 A chapter about escaping rules
Franz Glasner <fzglas.hg@dom66.de>
parents: 208
diff changeset
579
f20177032d21 A chapter about escaping rules
Franz Glasner <fzglas.hg@dom66.de>
parents: 208
diff changeset
580 Escaping Rules
f20177032d21 A chapter about escaping rules
Franz Glasner <fzglas.hg@dom66.de>
parents: 208
diff changeset
581 ==============
f20177032d21 A chapter about escaping rules
Franz Glasner <fzglas.hg@dom66.de>
parents: 208
diff changeset
582
f20177032d21 A chapter about escaping rules
Franz Glasner <fzglas.hg@dom66.de>
parents: 208
diff changeset
583 The escape character is a backslash ``\``.
f20177032d21 A chapter about escaping rules
Franz Glasner <fzglas.hg@dom66.de>
parents: 208
diff changeset
584
f20177032d21 A chapter about escaping rules
Franz Glasner <fzglas.hg@dom66.de>
parents: 208
diff changeset
585 A backslash can be escaped with ``\\`` and yields a single backslash token.
f20177032d21 A chapter about escaping rules
Franz Glasner <fzglas.hg@dom66.de>
parents: 208
diff changeset
586
f20177032d21 A chapter about escaping rules
Franz Glasner <fzglas.hg@dom66.de>
parents: 208
diff changeset
587 Within parameters a closing curly brace ``}`` ends the current
f20177032d21 A chapter about escaping rules
Franz Glasner <fzglas.hg@dom66.de>
parents: 208
diff changeset
588 parameters environment.
f20177032d21 A chapter about escaping rules
Franz Glasner <fzglas.hg@dom66.de>
parents: 208
diff changeset
589 It must be escaped using ``\}`` if a closing curly brace is part of the
f20177032d21 A chapter about escaping rules
Franz Glasner <fzglas.hg@dom66.de>
parents: 208
diff changeset
590 argument content.
f20177032d21 A chapter about escaping rules
Franz Glasner <fzglas.hg@dom66.de>
parents: 208
diff changeset
591
f20177032d21 A chapter about escaping rules
Franz Glasner <fzglas.hg@dom66.de>
parents: 208
diff changeset
592 A single backslash yields a :py:class:`pygments.token.Token.Generic.Error`
285
afbca50b7dc1 Implement an alternate syntax for "Explicit Token Types".
Franz Glasner <fzglas.hg@dom66.de>
parents: 284
diff changeset
593 token when in `default` and `expression` states
afbca50b7dc1 Implement an alternate syntax for "Explicit Token Types".
Franz Glasner <fzglas.hg@dom66.de>
parents: 284
diff changeset
594 (and also in `Explicit Token Types`_).
209
f20177032d21 A chapter about escaping rules
Franz Glasner <fzglas.hg@dom66.de>
parents: 208
diff changeset
595 Contrary---in `text` contexts a single backslash character that does not
f20177032d21 A chapter about escaping rules
Franz Glasner <fzglas.hg@dom66.de>
parents: 208
diff changeset
596 introduce a command yields a normal text token.
f20177032d21 A chapter about escaping rules
Franz Glasner <fzglas.hg@dom66.de>
parents: 208
diff changeset
597
f20177032d21 A chapter about escaping rules
Franz Glasner <fzglas.hg@dom66.de>
parents: 208
diff changeset
598 In all contexts a backslash that would normally introduce a known command
f20177032d21 A chapter about escaping rules
Franz Glasner <fzglas.hg@dom66.de>
parents: 208
diff changeset
599 must be escaped if the content should not recognized as a command.
f20177032d21 A chapter about escaping rules
Franz Glasner <fzglas.hg@dom66.de>
parents: 208
diff changeset
600
f20177032d21 A chapter about escaping rules
Franz Glasner <fzglas.hg@dom66.de>
parents: 208
diff changeset
601 Single- and double-quotes must be escaped also (``\"`` or ``\'``) in
f20177032d21 A chapter about escaping rules
Franz Glasner <fzglas.hg@dom66.de>
parents: 208
diff changeset
602 `default` and `expression` contexts when they should not introduce a
f20177032d21 A chapter about escaping rules
Franz Glasner <fzglas.hg@dom66.de>
parents: 208
diff changeset
603 string token.
f20177032d21 A chapter about escaping rules
Franz Glasner <fzglas.hg@dom66.de>
parents: 208
diff changeset
604
f20177032d21 A chapter about escaping rules
Franz Glasner <fzglas.hg@dom66.de>
parents: 208
diff changeset
605
144
b616f9645e37 More referencing with internal and external links
Franz Glasner <fzglas.hg@dom66.de>
parents: 142
diff changeset
606 .. _customized-sphinx-lexers:
b616f9645e37 More referencing with internal and external links
Franz Glasner <fzglas.hg@dom66.de>
parents: 142
diff changeset
607
125
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
608 Customized Lexers in Sphinx
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
609 ===========================
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
610
144
b616f9645e37 More referencing with internal and external links
Franz Glasner <fzglas.hg@dom66.de>
parents: 142
diff changeset
611 Defining lexers with non-default options in `Sphinx`_ can be done in its
153
d475f5e252eb Document an alternate variant to apply options to existing lexers
Franz Glasner <fzglas.hg@dom66.de>
parents: 150
diff changeset
612 configuration file :file:`conf.py`.
d475f5e252eb Document an alternate variant to apply options to existing lexers
Franz Glasner <fzglas.hg@dom66.de>
parents: 150
diff changeset
613
d475f5e252eb Document an alternate variant to apply options to existing lexers
Franz Glasner <fzglas.hg@dom66.de>
parents: 150
diff changeset
614 The first option is to apply the Sphinx config value ``highlight_options``
d475f5e252eb Document an alternate variant to apply options to existing lexers
Franz Glasner <fzglas.hg@dom66.de>
parents: 150
diff changeset
615 properly. An existing lexer can be customized by options.
d475f5e252eb Document an alternate variant to apply options to existing lexers
Franz Glasner <fzglas.hg@dom66.de>
parents: 150
diff changeset
616
d475f5e252eb Document an alternate variant to apply options to existing lexers
Franz Glasner <fzglas.hg@dom66.de>
parents: 150
diff changeset
617 A more flexible alternative is to define a new lexer in the Sphinx
d475f5e252eb Document an alternate variant to apply options to existing lexers
Franz Glasner <fzglas.hg@dom66.de>
parents: 150
diff changeset
618 application. The very same lexer class can be used with different options:
125
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
619
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
620 .. code-block:: python
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
621
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
622 from functools import partial
164
a4317957148b Move all lexers into a subpackage pygments_lexer_pseudocode2.lexers.
Franz Glasner <fzglas.hg@dom66.de>
parents: 162
diff changeset
623 from pygments_lexer_pseudocode2.lexers.algpseudocode import AlgPseudocodeLexer
125
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
624
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
625 def setup(app):
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
626
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
627 #
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
628 # Add a custom lexer: AlgPseudocodeLexer with custom init
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
629 # option "no_end".
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
630 #
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
631 # In modern Sphinx versions given lexer must be callable and may
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
632 # not be a lexer instance. So use an indirection with "partial"
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
633 # here.
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
634 #
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
635 app.add_lexer("noend-algpseudocode",
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
636 partial(AlgPseudocodeLexer, no_end=True))
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
637
294
Franz Glasner <fzglas.hg@dom66.de>
parents: 290
diff changeset
638 .. _note-raiseonerror-filter:
125
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
639
158
f08d77b8cbf7 Document the default filter "raiseonerror" that is applied by Sphinx by default for lexers
Franz Glasner <fzglas.hg@dom66.de>
parents: 156
diff changeset
640 .. note:: Lexers in Sphinx are instantiated with the `raiseonerror` filter
f08d77b8cbf7 Document the default filter "raiseonerror" that is applied by Sphinx by default for lexers
Franz Glasner <fzglas.hg@dom66.de>
parents: 156
diff changeset
641 applied by default.
f08d77b8cbf7 Document the default filter "raiseonerror" that is applied by Sphinx by default for lexers
Franz Glasner <fzglas.hg@dom66.de>
parents: 156
diff changeset
642 This is also true for custom lexers that are added by
f08d77b8cbf7 Document the default filter "raiseonerror" that is applied by Sphinx by default for lexers
Franz Glasner <fzglas.hg@dom66.de>
parents: 156
diff changeset
643 :py:meth:`Sphinx.add_lexer`.
207
76053daf813e Extend the note in "Customized Lexers in Sphinx" somewhat
Franz Glasner <fzglas.hg@dom66.de>
parents: 201
diff changeset
644 Using the `filters` option the user can associate custom filters
76053daf813e Extend the note in "Customized Lexers in Sphinx" somewhat
Franz Glasner <fzglas.hg@dom66.de>
parents: 201
diff changeset
645 with a lexer.
76053daf813e Extend the note in "Customized Lexers in Sphinx" somewhat
Franz Glasner <fzglas.hg@dom66.de>
parents: 201
diff changeset
646 These filters have precedence over the default `raiseonerror`
76053daf813e Extend the note in "Customized Lexers in Sphinx" somewhat
Franz Glasner <fzglas.hg@dom66.de>
parents: 201
diff changeset
647 filter.
158
f08d77b8cbf7 Document the default filter "raiseonerror" that is applied by Sphinx by default for lexers
Franz Glasner <fzglas.hg@dom66.de>
parents: 156
diff changeset
648
f08d77b8cbf7 Document the default filter "raiseonerror" that is applied by Sphinx by default for lexers
Franz Glasner <fzglas.hg@dom66.de>
parents: 156
diff changeset
649 Lexer *instances* that are added to
f08d77b8cbf7 Document the default filter "raiseonerror" that is applied by Sphinx by default for lexers
Franz Glasner <fzglas.hg@dom66.de>
parents: 156
diff changeset
650 :py:data:`sphinx.highlighting.lexers` somehow are taken as is by
f08d77b8cbf7 Document the default filter "raiseonerror" that is applied by Sphinx by default for lexers
Franz Glasner <fzglas.hg@dom66.de>
parents: 156
diff changeset
651 Sphinx and are not augmented with any default filters.
f08d77b8cbf7 Document the default filter "raiseonerror" that is applied by Sphinx by default for lexers
Franz Glasner <fzglas.hg@dom66.de>
parents: 156
diff changeset
652
294
Franz Glasner <fzglas.hg@dom66.de>
parents: 290
diff changeset
653 See also chapter :ref:`filters`.
269
9790553d7225 More details on custom filters in the documentation
Franz Glasner <fzglas.hg@dom66.de>
parents: 268
diff changeset
654
125
3629bf09b30d Much more documentation including most details of the AlgPseudocodeLexer
Franz Glasner <fzglas.hg@dom66.de>
parents: 88
diff changeset
655 For older Sphinx versions your mileage may vary.
169
3c517c22df9c Much more details and refinements in the docs
Franz Glasner <fzglas.hg@dom66.de>
parents: 168
diff changeset
656
3c517c22df9c Much more details and refinements in the docs
Franz Glasner <fzglas.hg@dom66.de>
parents: 168
diff changeset
657
3c517c22df9c Much more details and refinements in the docs
Franz Glasner <fzglas.hg@dom66.de>
parents: 168
diff changeset
658 Some Examples
3c517c22df9c Much more details and refinements in the docs
Franz Glasner <fzglas.hg@dom66.de>
parents: 168
diff changeset
659 =============
3c517c22df9c Much more details and refinements in the docs
Franz Glasner <fzglas.hg@dom66.de>
parents: 168
diff changeset
660
266
50bd1e91b822 Doc enhancements: style, sub-headings, wording, examples, details
Franz Glasner <fzglas.hg@dom66.de>
parents: 265
diff changeset
661 .. rubric:: Synthetic Example
50bd1e91b822 Doc enhancements: style, sub-headings, wording, examples, details
Franz Glasner <fzglas.hg@dom66.de>
parents: 265
diff changeset
662
50bd1e91b822 Doc enhancements: style, sub-headings, wording, examples, details
Franz Glasner <fzglas.hg@dom66.de>
parents: 265
diff changeset
663 The first example is a synthetic example with many features.
187
418846a2623c Also link to exampled from the PDF properly
Franz Glasner <fzglas.hg@dom66.de>
parents: 186
diff changeset
664
418846a2623c Also link to exampled from the PDF properly
Franz Glasner <fzglas.hg@dom66.de>
parents: 186
diff changeset
665 .. only:: builder_html
418846a2623c Also link to exampled from the PDF properly
Franz Glasner <fzglas.hg@dom66.de>
parents: 186
diff changeset
666
418846a2623c Also link to exampled from the PDF properly
Franz Glasner <fzglas.hg@dom66.de>
parents: 186
diff changeset
667 Its source code is in :download:`examples/example-1.pseudocode`.
418846a2623c Also link to exampled from the PDF properly
Franz Glasner <fzglas.hg@dom66.de>
parents: 186
diff changeset
668
418846a2623c Also link to exampled from the PDF properly
Franz Glasner <fzglas.hg@dom66.de>
parents: 186
diff changeset
669 .. raw:: latex
418846a2623c Also link to exampled from the PDF properly
Franz Glasner <fzglas.hg@dom66.de>
parents: 186
diff changeset
670
418846a2623c Also link to exampled from the PDF properly
Franz Glasner <fzglas.hg@dom66.de>
parents: 186
diff changeset
671 Its source code can be found at \url{example-1.pseudocode}.
169
3c517c22df9c Much more details and refinements in the docs
Franz Glasner <fzglas.hg@dom66.de>
parents: 168
diff changeset
672
3c517c22df9c Much more details and refinements in the docs
Franz Glasner <fzglas.hg@dom66.de>
parents: 168
diff changeset
673 .. literalinclude:: examples/example-1.pseudocode
3c517c22df9c Much more details and refinements in the docs
Franz Glasner <fzglas.hg@dom66.de>
parents: 168
diff changeset
674 :language: algpseudocode
3c517c22df9c Much more details and refinements in the docs
Franz Glasner <fzglas.hg@dom66.de>
parents: 168
diff changeset
675 :lines: 2-
3c517c22df9c Much more details and refinements in the docs
Franz Glasner <fzglas.hg@dom66.de>
parents: 168
diff changeset
676
266
50bd1e91b822 Doc enhancements: style, sub-headings, wording, examples, details
Franz Glasner <fzglas.hg@dom66.de>
parents: 265
diff changeset
677 The highlighted output with a customized `AlgPseudocodeLexer` and its `no_end`
50bd1e91b822 Doc enhancements: style, sub-headings, wording, examples, details
Franz Glasner <fzglas.hg@dom66.de>
parents: 265
diff changeset
678 option set to :py:obj:`True`:
169
3c517c22df9c Much more details and refinements in the docs
Franz Glasner <fzglas.hg@dom66.de>
parents: 168
diff changeset
679
3c517c22df9c Much more details and refinements in the docs
Franz Glasner <fzglas.hg@dom66.de>
parents: 168
diff changeset
680 .. literalinclude:: examples/example-1.pseudocode
3c517c22df9c Much more details and refinements in the docs
Franz Glasner <fzglas.hg@dom66.de>
parents: 168
diff changeset
681 :language: NoEndAlgPseudocode
3c517c22df9c Much more details and refinements in the docs
Franz Glasner <fzglas.hg@dom66.de>
parents: 168
diff changeset
682 :lines: 2-
3c517c22df9c Much more details and refinements in the docs
Franz Glasner <fzglas.hg@dom66.de>
parents: 168
diff changeset
683
266
50bd1e91b822 Doc enhancements: style, sub-headings, wording, examples, details
Franz Glasner <fzglas.hg@dom66.de>
parents: 265
diff changeset
684 .. rubric:: Dinic's Algorithm
50bd1e91b822 Doc enhancements: style, sub-headings, wording, examples, details
Franz Glasner <fzglas.hg@dom66.de>
parents: 265
diff changeset
685
186
95754197f5b3 Link to some source code of example pseudocode files
Franz Glasner <fzglas.hg@dom66.de>
parents: 172
diff changeset
686 The second example is Wikipedia's description of *Dinic's Algorithm*
95754197f5b3 Link to some source code of example pseudocode files
Franz Glasner <fzglas.hg@dom66.de>
parents: 172
diff changeset
687 (see https://en.wikipedia.org/wiki/Dinic%27s_algorithm).
187
418846a2623c Also link to exampled from the PDF properly
Franz Glasner <fzglas.hg@dom66.de>
parents: 186
diff changeset
688
418846a2623c Also link to exampled from the PDF properly
Franz Glasner <fzglas.hg@dom66.de>
parents: 186
diff changeset
689 .. only:: builder_html
418846a2623c Also link to exampled from the PDF properly
Franz Glasner <fzglas.hg@dom66.de>
parents: 186
diff changeset
690
418846a2623c Also link to exampled from the PDF properly
Franz Glasner <fzglas.hg@dom66.de>
parents: 186
diff changeset
691 Its source code is in :download:`examples/algorithm-dinic.pseudocode`.
169
3c517c22df9c Much more details and refinements in the docs
Franz Glasner <fzglas.hg@dom66.de>
parents: 168
diff changeset
692
187
418846a2623c Also link to exampled from the PDF properly
Franz Glasner <fzglas.hg@dom66.de>
parents: 186
diff changeset
693 .. raw:: latex
418846a2623c Also link to exampled from the PDF properly
Franz Glasner <fzglas.hg@dom66.de>
parents: 186
diff changeset
694
266
50bd1e91b822 Doc enhancements: style, sub-headings, wording, examples, details
Franz Glasner <fzglas.hg@dom66.de>
parents: 265
diff changeset
695 Its source code can be found at \url{algorithm-dinic.pseudocode}.
187
418846a2623c Also link to exampled from the PDF properly
Franz Glasner <fzglas.hg@dom66.de>
parents: 186
diff changeset
696
418846a2623c Also link to exampled from the PDF properly
Franz Glasner <fzglas.hg@dom66.de>
parents: 186
diff changeset
697 .. literalinclude:: examples/algorithm-dinic.pseudocode
169
3c517c22df9c Much more details and refinements in the docs
Franz Glasner <fzglas.hg@dom66.de>
parents: 168
diff changeset
698 :language: algpseudocode
3c517c22df9c Much more details and refinements in the docs
Franz Glasner <fzglas.hg@dom66.de>
parents: 168
diff changeset
699 :lines: 2-
3c517c22df9c Much more details and refinements in the docs
Franz Glasner <fzglas.hg@dom66.de>
parents: 168
diff changeset
700
266
50bd1e91b822 Doc enhancements: style, sub-headings, wording, examples, details
Franz Glasner <fzglas.hg@dom66.de>
parents: 265
diff changeset
701 .. rubric:: Ford–Fulkerson Algorithm
50bd1e91b822 Doc enhancements: style, sub-headings, wording, examples, details
Franz Glasner <fzglas.hg@dom66.de>
parents: 265
diff changeset
702
186
95754197f5b3 Link to some source code of example pseudocode files
Franz Glasner <fzglas.hg@dom66.de>
parents: 172
diff changeset
703 The third example is Wikipedia's pseudocode of the *Ford–Fulkerson Algorithm*
95754197f5b3 Link to some source code of example pseudocode files
Franz Glasner <fzglas.hg@dom66.de>
parents: 172
diff changeset
704 (see https://en.wikipedia.org/wiki/Ford%E2%80%93Fulkerson_algorithm).
187
418846a2623c Also link to exampled from the PDF properly
Franz Glasner <fzglas.hg@dom66.de>
parents: 186
diff changeset
705
418846a2623c Also link to exampled from the PDF properly
Franz Glasner <fzglas.hg@dom66.de>
parents: 186
diff changeset
706 .. only:: builder_html
418846a2623c Also link to exampled from the PDF properly
Franz Glasner <fzglas.hg@dom66.de>
parents: 186
diff changeset
707
418846a2623c Also link to exampled from the PDF properly
Franz Glasner <fzglas.hg@dom66.de>
parents: 186
diff changeset
708 Its source code is in
418846a2623c Also link to exampled from the PDF properly
Franz Glasner <fzglas.hg@dom66.de>
parents: 186
diff changeset
709 :download:`examples/algorithm-ford-fulkerson.pseudocode`.
418846a2623c Also link to exampled from the PDF properly
Franz Glasner <fzglas.hg@dom66.de>
parents: 186
diff changeset
710
418846a2623c Also link to exampled from the PDF properly
Franz Glasner <fzglas.hg@dom66.de>
parents: 186
diff changeset
711 .. raw:: latex
418846a2623c Also link to exampled from the PDF properly
Franz Glasner <fzglas.hg@dom66.de>
parents: 186
diff changeset
712
418846a2623c Also link to exampled from the PDF properly
Franz Glasner <fzglas.hg@dom66.de>
parents: 186
diff changeset
713 Its source code can be found at \url{algorithm-ford-fulkerson.pseudocode}.
169
3c517c22df9c Much more details and refinements in the docs
Franz Glasner <fzglas.hg@dom66.de>
parents: 168
diff changeset
714
3c517c22df9c Much more details and refinements in the docs
Franz Glasner <fzglas.hg@dom66.de>
parents: 168
diff changeset
715 .. literalinclude:: examples/algorithm-ford-fulkerson.pseudocode
3c517c22df9c Much more details and refinements in the docs
Franz Glasner <fzglas.hg@dom66.de>
parents: 168
diff changeset
716 :language: algpseudocode
3c517c22df9c Much more details and refinements in the docs
Franz Glasner <fzglas.hg@dom66.de>
parents: 168
diff changeset
717 :lines: 2-
3c517c22df9c Much more details and refinements in the docs
Franz Glasner <fzglas.hg@dom66.de>
parents: 168
diff changeset
718
266
50bd1e91b822 Doc enhancements: style, sub-headings, wording, examples, details
Franz Glasner <fzglas.hg@dom66.de>
parents: 265
diff changeset
719 .. rubric:: Edmonds–Karp Algorithm
50bd1e91b822 Doc enhancements: style, sub-headings, wording, examples, details
Franz Glasner <fzglas.hg@dom66.de>
parents: 265
diff changeset
720
186
95754197f5b3 Link to some source code of example pseudocode files
Franz Glasner <fzglas.hg@dom66.de>
parents: 172
diff changeset
721 The fourth example is Wikipedia's pseudocode of the *Edmonds–Karp Algorithm*
169
3c517c22df9c Much more details and refinements in the docs
Franz Glasner <fzglas.hg@dom66.de>
parents: 168
diff changeset
722 (see https://en.wikipedia.org/wiki/Edmonds%E2%80%93Karp_algorithm)
194
403b500e0ed4 FIX: Syntax
Franz Glasner <fzglas.hg@dom66.de>
parents: 193
diff changeset
723 with a custom lexer which skips all ``ENDxxx`` keywords.
187
418846a2623c Also link to exampled from the PDF properly
Franz Glasner <fzglas.hg@dom66.de>
parents: 186
diff changeset
724
418846a2623c Also link to exampled from the PDF properly
Franz Glasner <fzglas.hg@dom66.de>
parents: 186
diff changeset
725 .. only:: builder_html
418846a2623c Also link to exampled from the PDF properly
Franz Glasner <fzglas.hg@dom66.de>
parents: 186
diff changeset
726
418846a2623c Also link to exampled from the PDF properly
Franz Glasner <fzglas.hg@dom66.de>
parents: 186
diff changeset
727 Its source code is in
418846a2623c Also link to exampled from the PDF properly
Franz Glasner <fzglas.hg@dom66.de>
parents: 186
diff changeset
728 :download:`examples/algorithm-edmonds-karp.pseudocode`.
418846a2623c Also link to exampled from the PDF properly
Franz Glasner <fzglas.hg@dom66.de>
parents: 186
diff changeset
729
418846a2623c Also link to exampled from the PDF properly
Franz Glasner <fzglas.hg@dom66.de>
parents: 186
diff changeset
730 .. raw:: latex
418846a2623c Also link to exampled from the PDF properly
Franz Glasner <fzglas.hg@dom66.de>
parents: 186
diff changeset
731
418846a2623c Also link to exampled from the PDF properly
Franz Glasner <fzglas.hg@dom66.de>
parents: 186
diff changeset
732 Its source code can be found at \url{algorithm-edmonds-karp.pseudocode}.
169
3c517c22df9c Much more details and refinements in the docs
Franz Glasner <fzglas.hg@dom66.de>
parents: 168
diff changeset
733
3c517c22df9c Much more details and refinements in the docs
Franz Glasner <fzglas.hg@dom66.de>
parents: 168
diff changeset
734 .. literalinclude:: examples/algorithm-edmonds-karp.pseudocode
3c517c22df9c Much more details and refinements in the docs
Franz Glasner <fzglas.hg@dom66.de>
parents: 168
diff changeset
735 :language: NoEndAlgPseudocode
3c517c22df9c Much more details and refinements in the docs
Franz Glasner <fzglas.hg@dom66.de>
parents: 168
diff changeset
736 :lines: 2-
3c517c22df9c Much more details and refinements in the docs
Franz Glasner <fzglas.hg@dom66.de>
parents: 168
diff changeset
737
186
95754197f5b3 Link to some source code of example pseudocode files
Franz Glasner <fzglas.hg@dom66.de>
parents: 172
diff changeset
738 And now the *Edmonds–Karp Algorithm* with **french** keywords:
169
3c517c22df9c Much more details and refinements in the docs
Franz Glasner <fzglas.hg@dom66.de>
parents: 168
diff changeset
739
3c517c22df9c Much more details and refinements in the docs
Franz Glasner <fzglas.hg@dom66.de>
parents: 168
diff changeset
740 .. literalinclude:: examples/algorithm-edmonds-karp.pseudocode
3c517c22df9c Much more details and refinements in the docs
Franz Glasner <fzglas.hg@dom66.de>
parents: 168
diff changeset
741 :language: algpseudocode-fr
3c517c22df9c Much more details and refinements in the docs
Franz Glasner <fzglas.hg@dom66.de>
parents: 168
diff changeset
742 :lines: 2-
3c517c22df9c Much more details and refinements in the docs
Franz Glasner <fzglas.hg@dom66.de>
parents: 168
diff changeset
743
186
95754197f5b3 Link to some source code of example pseudocode files
Franz Glasner <fzglas.hg@dom66.de>
parents: 172
diff changeset
744 And again the *Edmonds–Karp Algorithm* with **german** keywords:
169
3c517c22df9c Much more details and refinements in the docs
Franz Glasner <fzglas.hg@dom66.de>
parents: 168
diff changeset
745
3c517c22df9c Much more details and refinements in the docs
Franz Glasner <fzglas.hg@dom66.de>
parents: 168
diff changeset
746 .. literalinclude:: examples/algorithm-edmonds-karp.pseudocode
3c517c22df9c Much more details and refinements in the docs
Franz Glasner <fzglas.hg@dom66.de>
parents: 168
diff changeset
747 :language: algpseudocode-de
3c517c22df9c Much more details and refinements in the docs
Franz Glasner <fzglas.hg@dom66.de>
parents: 168
diff changeset
748 :lines: 2-