Mercurial > hgrepos > Python > libs > pygments-lexer-pseudocode2
comparison docs/lexer-algpseudocode.rst @ 289:6fc7f9c1d89d
Remove the old implementation of explicit token types completely
| author | Franz Glasner <fzglas.hg@dom66.de> |
|---|---|
| date | Fri, 22 May 2026 12:41:08 +0200 |
| parents | 298841bc4dee |
| children | 3e2f7ca64894 |
comparison
equal
deleted
inserted
replaced
| 288:298841bc4dee | 289:6fc7f9c1d89d |
|---|---|
| 466 | 466 |
| 467 Explicit Token Types | 467 Explicit Token Types |
| 468 ==================== | 468 ==================== |
| 469 | 469 |
| 470 They allow to handle keywords and operators that are not recognized by default. | 470 They allow to handle keywords and operators that are not recognized by default. |
| 471 And they allow the user to explicitely highlight some input text at low-level. | 471 And they allow the user to explicitely highlight some input text with |
| 472 | 472 a low-level command. |
| 473 .. note:: Explicit token types are **case-sensitive**. | 473 |
| 474 | 474 They are implemented with the ``\ttX{ARG1}{ARG2}`` command. |
| 475 .. note:: Explicit token types work in all `expression` and `text` contexts. | |
| 476 | |
| 477 .. note:: Nested explicit token types are *not supported*. | |
| 478 | |
| 479 | |
| 480 Current and Recommended Syntax | |
| 481 ------------------------------ | |
| 482 | |
| 483 The current and recommended use is the ``\ttX{ARG1}{ARG2}`` command. | |
| 484 | 475 |
| 485 This command has two required parameters: | 476 This command has two required parameters: |
| 486 | 477 |
| 487 #. The content of the first argument `ARG1` can be one of | 478 #. The content of the first argument `ARG1` can be one of |
| 488 | 479 |
| 514 | 505 |
| 515 #. The content of the second argument will given the token type of | 506 #. The content of the second argument will given the token type of |
| 516 the first parameter. | 507 the first parameter. |
| 517 | 508 |
| 518 Standard `Escaping Rules`_ apply to this argument! | 509 Standard `Escaping Rules`_ apply to this argument! |
| 510 | |
| 511 .. note:: The command for explicit token types is **case-sensitive**. | |
| 519 | 512 |
| 520 .. rubric:: Examples: | 513 .. rubric:: Examples: |
| 521 | 514 |
| 522 .. code-block:: algpseudocode | 515 .. code-block:: algpseudocode |
| 523 | 516 |
| 572 | 565 |
| 573 .. code-block:: nonstrict-algpseudocode | 566 .. code-block:: nonstrict-algpseudocode |
| 574 | 567 |
| 575 \text{• \\ttX{Generic.Not.Yet.Existing\}{∈_∌\}(p1, p2)} \ttX{Generic.Not.Yet.Existing}{∈_∌}(p1, p2) | 568 \text{• \\ttX{Generic.Not.Yet.Existing\}{∈_∌\}(p1, p2)} \ttX{Generic.Not.Yet.Existing}{∈_∌}(p1, p2) |
| 576 | 569 |
| 577 | 570 .. note:: Explicit token types work in all `expression` and `text` contexts. |
| 578 Old Syntax (Deprecated) | 571 |
| 579 ----------------------- | 572 .. note:: Nested explicit token types are *not supported*. |
| 580 | |
| 581 .. deprecated:: 3.0 | |
| 582 Use `Current and Recommended Syntax`_ instead. | |
| 583 | |
| 584 .. note:: The lower-case ``x`` in ``\ttx-``! | |
| 585 | |
| 586 `XX` represents a `value` in the :py:data:`pygments.token.STANDARD_TYPES` | |
| 587 dict. | |
| 588 Its corresponding token type (the associated `key` in this `dict`) is | |
| 589 used as token type. | |
| 590 | |
| 591 ``\tt-XX/SINGLE-CHAR`` | |
| 592 | |
| 593 no escaping needed | |
| 594 | |
| 595 `SINGLE-CHAR` is a single character and can be *every* character | |
| 596 (including a carriage-return or line-feed) | |
| 597 | |
| 598 ``\ttx-XX{CHARACTERS}`` | |
| 599 | |
| 600 ``\ttx-XX(CHARACTERS)`` | |
| 601 | |
| 602 ``\ttx-XX[CHARACTERS]`` | |
| 603 | |
| 604 ``\ttx-XX<CHARACTERS>`` | |
| 605 | |
| 606 ``\ttx-XX<SEP>CHARACTERS<SEP>`` | |
| 607 | |
| 608 No escaping possible! There are enough alternatives available! | |
| 609 | |
| 610 `SEP` is exactly one character of ``/?.,:;%|=*+!\$~"'_-#@``. | |
| 611 | |
| 612 | |
| 613 Examples: | |
| 614 | |
| 615 .. code-block:: algpseudocode | |
| 616 | |
| 617 \text{• \\tt-kc/C} \tt-kc/C \rem C as Keyword.Constant | |
| 618 \text{• \\tt-ow/∈} \tt-ow/∈ \rem ∈ as Operator.Word | |
| 619 \text{• \\ttx-kc{A Constant Keyword\}} \ttx-kc{A Constant Keyword} \rem An explicit Keyword.Constant | |
| 620 \text{• \\ttx-nv{A Variable Name\}} \ttx-nv{A Variable Name} \rem An explicit Name.Variable | |
| 621 \text{• \\ttx-ni{An Entity*Name\}} \ttx-ni{An Entity*Name} \rem An explicit Name.Entity | |
| 622 \text{• \\ttx-k(∈ ∌)} \ttx-k(∈ ∌) \rem ∈ and ∌ as (ordinary) Keywords | |
| 623 \text{• \\ttx-o<∈ ∌>} \ttx-o<∈ ∌> \rem ∈ and ∌ as (ordinary) Operators | |
| 624 /* | |
| 625 * The line below has ∈_∌ as (peculiar) function name. | |
| 626 * Their params are automatic (i.e. a normal expression). | |
| 627 */ | |
| 628 \text{• \\ttx-nf<∈_∌>(p1, p2)} \ttx-nf<∈_∌>(p1, p2) | |
| 629 /* | |
| 630 * The line below has ∈_∌ as (peculiar) decorator name (as used in Python). | |
| 631 * Their params are automatic (i.e. a normal expression). | |
| 632 */ | |
| 633 \text{• \\ttx-nd[∈_∌](p1, p2)} \ttx-nd[∈_∌](p1, p2) | |
| 634 /* | |
| 635 * Normal emphasis ("strong") | |
| 636 */ | |
| 637 \text{• \\ttx-gs$this is strong$} \ttx-gs$this is strong$ | |
| 638 /* | |
| 639 * A strong emphasis. | |
| 640 * Note that the backslash is a valid delimiter! | |
| 641 */ | |
| 642 \text{• \\ttx-ges\\strong emphasis!\\} \ttx-ges\strong emphasis!\ | |
| 643 /* | |
| 644 * This is a non-existing token type: you get some generic error markup | |
| 645 * with a Generic.Error token and no expansion. | |
| 646 */ | |
| 647 \text{• \\ttx-NON-EXISTING?∈_∌?(p1, p2)} \ttx-NON_EXISTING?∈_∌?(p1, p2) | |
| 648 | 573 |
| 649 | 574 |
| 650 .. _escaping-rules: | 575 .. _escaping-rules: |
| 651 | 576 |
| 652 Escaping Rules | 577 Escaping Rules |
