pygments-lexer-pseudocode-i18n
| Resource | Link | Purpose |
|---|---|---|
| pygments-lexer-pseudocode-i18n — repository | gitlab.com/rod2ik/pygments-lexer-pseudocode-i18n | Multilingual Pygments syntax highlighting for Pseudocode |
| pygments-lexer-pseudocode-i18n — documentation | rod2ik.gitlab.io/pygments-lexer-pseudocode-i18n | Complete user and developer documentation |
| pseudocode-i18n | gitlab.com/rod2ik/pseudocode-i18n | Shared grammar, language detection, formatter, Python transpiler and flowcharts |
| mkdocs-pseudocode-i18n | gitlab.com/rod2ik/mkdocs-pseudocode-i18n | MkDocs integration for pseudocode teaching/documentation sites |
| vscode-pseudocode | gitlab.com/rod2ik/vscode-pseudocode | VS Code / Open VSX editing experience for .pseudo files |
Current version: 0.3.0.
Requires: pseudocode-i18n >= 0.3, < 0.4.
License: GNU GPL-3.0-or-later.
pygments-lexer-pseudocode-i18n gives the multilingual language defined by pseudocode-i18n Python-like Pygments syntax highlighting without duplicating the grammar.
Write one normal .pseudo file in French, Spanish, Italian, Portuguese, German or English. The generic pseudocode lexer detects the source language automatically, understands the same # language: xx override as the core, and maps pseudocode concepts to the same token families used by Pygments for Python.
# language: fr
notes est un tableau
absent = Vide
Répéter 5 fois:
Si note ∉ notes Alors:
Écrire "Note inconnue"
Sinon:
Afficher note
Fin
Fin
Types such as entier, tableau, dictionnaire, ensemble and tuple are highlighted like Python built-in types; Vide is highlighted like Python None; localized boolean/membership operators are highlighted like Python word operators.
Why this lexer?
A pseudocode lexer becomes difficult to maintain if every editor, MkDocs plugin and highlighter carries its own handwritten list of translated keywords. This project deliberately avoids that problem.
The grammar and vocabulary come from pseudocode-i18n, so the lexer automatically follows the shared language definitions for:
Si ... Alors,Sinon Si,Sinon,Finand optional specific end markers;Pour,Tant Que,Répéter N foisandRépéter ... Jusqu'à;Afficher/Écrire,Saisir/Lire,Mostrar/Escribir, and other localized synonyms;- optional type declarations, including arrays/lists, dictionaries, sets and tuples;
- localized
Vrai/Faux/Vide-style constants; Dans,Non Dans,Non Inclus Dans,∈and∉;=,:=, arrows, arithmetic/comparison operators, strings, numbers and comments;- localized functions and methods;
- project-specific vocabulary added through
pseudocode.config.yml.
Install
python -m pip install pygments-lexer-pseudocode-i18n
The core dependency is installed automatically:
pseudocode-i18n >= 0.3, < 0.4
On a system-managed Python installation where you deliberately use user/system packages:
python -m pip install --break-system-packages pygments-lexer-pseudocode-i18n
One .pseudo extension
Pseudocode 0.3 uses one source extension for every language:
algorithm.pseudo
The old language-bearing filename extensions such as .pseudo-fr, .pseudo-es and .pseudocode-fr are not part of the 0.3 file model.
For normal use, select the generic lexer:
pseudocode
or its short alias:
pseudo
The lexer resolves the language in the same order as the core:
explicit lexer option > # language: xx > project configuration > automatic detection > fallback
For example:
# language: es
Si nota >= 10 Entonces:
Escribir "Aprobado"
Sino:
Mostrar "No aprobado"
Fin
The directive is optional; normal source can simply be detected from its grammar.
Pseudocode in several languages
The bundled language documentation follows the project order: French, Spanish, Italian, Portuguese, German, then English.
Français
Si note >= 10 Alors:
Afficher "Admis"
Sinon:
Écrire "Ajourné"
Fin
Español
Si nota >= 10 Entonces:
Mostrar "Aprobado"
Sino:
Escribir "No aprobado"
Fin
Italiano
Se voto >= 10 Allora:
Mostra "Promosso"
Altrimenti:
Mostra "Non promosso"
Fine
Português
Se nota >= 10 Então:
Mostrar "Aprovado"
Senão:
Mostrar "Reprovado"
Fim
Deutsch
Wenn note >= 10 Dann:
Ausgeben "Bestanden"
Sonst:
Ausgeben "Nicht bestanden"
Ende
English
If grade >= 10 Then:
Display "Passed"
Else:
Display "Failed"
End
Python-like token categories
The visual goal is to reuse Pygments' Python token families as closely as possible, so existing Pygments themes behave naturally.
| Pseudocode role | Pygments token family | Python analogue |
|---|---|---|
| structural control flow | Keyword |
if, else, for, while |
Renvoyer, etc. |
Keyword |
return |
Vrai, Faux, Vide, etc. |
Keyword.Constant |
True, False, None |
| localized types | Name.Builtin |
int, list, dict, set, tuple |
Afficher, Écrire, Saisir, etc. |
Name.Builtin |
print, input |
| localized word operators | Operator.Word |
and, or, not, in, not in |
∈, ∉ |
Operator.Word |
in, not in |
| function declaration name | Name.Function |
Python function name |
| class declaration name | Name.Class |
Python class name |
| strings/numbers/operators | Python-like String, Number.*, Operator families |
equivalent Python lexical role |
This is intentional: the project does not invent a separate theme model when Pygments already has mature Python-compatible styles.
Command line with pygmentize
Once installed, highlight any .pseudo file with automatic language detection:
pygmentize -l pseudocode -f terminal256 algorithm.pseudo
Generate HTML:
pygmentize -l pseudocode -f html -o algorithm.html algorithm.pseudo
Language-specific aliases remain available as explicit lexer choices when an integration already knows the language:
pseudocode-fr / pseudo-fr
pseudocode-es / pseudo-es
pseudocode-it / pseudo-it
pseudocode-pt / pseudo-pt
pseudocode-de / pseudo-de
pseudocode-en / pseudo-en
They no longer imply language-specific file extensions.
Python API
Automatic detection:
from pygments import highlight
from pygments.formatters import HtmlFormatter
from pygments_lexer_pseudocode_i18n import PseudocodeLexer
source = """\
Si note >= 10 Alors:
Afficher "Admis"
Fin
"""
html = highlight(source, PseudocodeLexer(), HtmlFormatter())
Force a language through the generic lexer:
lexer = PseudocodeLexer(language="es")
Or use an explicit class:
from pygments_lexer_pseudocode_i18n import PseudocodeFrenchLexer
lexer = PseudocodeFrenchLexer()
The explicit API choice has priority over a # language: xx directive, just as an explicit language argument does in pseudocode-i18n.
Markdown and MkDocs
After the package is installed in the environment used to build the documentation, Pygments-aware Markdown integrations can use the generic alias:
```pseudocode
# language: fr
Si x ∈ valeurs Alors:
Afficher x
Fin
```
This is the preferred fence for multilingual content because it follows the same automatic language model as .pseudo files.
If a site already knows the language externally, explicit aliases such as pseudocode-fr are still available.
Shared project configuration
The generic lexer reads the same pseudocode.config.yml as pseudocode-i18n.
Typical configuration:
language: auto
fallback_language: fr
languages:
fr:
keywords:
display:
add:
- Montrer
Then this custom spelling is highlighted without modifying this lexer:
Montrer "Bonjour"
Language-specific lexer classes keep their explicit language while still consuming that language's project overrides.
Relationship with the other Pseudocode projects
This package highlights pseudocode. It intentionally delegates semantics to the shared ecosystem:
pseudocode-i18n
├── grammar / i18n / language detection
├── formatter
├── Python transpilation / execution
├── Mermaid flowcharts / algorigrammes
└── highlighting vocabulary
│
▼
pygments-lexer-pseudocode-i18n
│
├── Pygments / HTML / terminal highlighting
├── MkDocs code highlighting
└── reusable token stream for integrations
For example, Python transpilation and flowchart generation belong to pseudocode-i18n:
pseudo transpile algorithm.pseudo
pseudo flowchart algorithm.pseudo
This separation keeps the lexer small while guaranteeing that it follows the same language rules.
Development
Bootstrap the project:
corepack enable
yarn setup
When a sibling ../pseudocode-i18n checkout exists, yarn setup installs it editable first; otherwise the compatible dependency is resolved normally.
Run tests:
yarn test
Run documentation locally:
yarn dev
Expose it on the LAN:
yarn dev:lan
Full validation:
yarn bfc
yarn bfc synchronizes the version, checks version consistency, lints, runs the lexer regression suite, regenerates/checks/builds the documentation strictly, and builds the Python package.
Version source of truth
package.json is the single source of truth for this project's version.
yarn version:sync
synchronizes pyproject.toml, pygments_lexer_pseudocode_i18n.__version__ and the version marker in this README.
Narrative/generated MkDocs pages can use:
__PYGMENTS_LEXER_PSEUDOCODE_I18N_VERSION__
and site/hooks/version.py replaces it from package.json at build time.
Documentation policy
Documentation is part of every change. A change to the shared grammar, supported token categories, language resolution, aliases, configuration, packaging or workflow must update the corresponding documentation in the same revision.
The MkDocs home page is generated from this README so the repository landing page and documentation landing page cannot silently drift apart.
Release workflow
A normal push updates the project and GitLab Pages without creating a release.
Before release, run:
yarn bfc
The tag must match the version in package.json; CI validates that invariant before publishing.
With the project push helper used by this ecosystem, a normal update remains:
push "message"
and a release is requested with the current package.json version:
push "release <version>" --release
License
GNU General Public License version 3 or later (GPL-3.0-or-later). See LICENSE.
AUTRES PROJETS de ce développeur
The Pseudocode ecosystem is intentionally split into reusable projects sharing one grammar:
- pseudocode-i18n — multilingual parser, formatter, Python transpiler, executor, language detection and Mermaid algorigram export.
- mkdocs-pseudocode-i18n — MkDocs integration for pseudocode blocks and educational documentation.
- vscode-pseudocode — VS Code / Open VSX editing support for
.pseudofiles.
The documentation for this lexer is published at rod2ik.gitlab.io/pygments-lexer-pseudocode-i18n.
Release files for pygments-lexer-pseudocode-i18n 0.3.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| pygments_lexer_pseudocode_i18n-0.3.0.tar.gz | 50.0 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pygments_lexer_pseudocode_i18n-0.3.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 72.6 kB
Release files / pygments_lexer_pseudocode_i18n-0.3.0.tar.gz
| Download URL | pygments_lexer_pseudocode_i18n-0.3.0.tar.gz |
|---|---|
| Size | 50.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2412391412fb0acf6b816109cc9bf7df8ddc0a650557e3fdaa7b0f669545480b
|
|
BLAKE2b-256 checksum How to use checksums |
8806338b8d550e2b652ec1512ddba08e70ba781ae188db5cfa081b5b0512498e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.15
|
Release files / pygments_lexer_pseudocode_i18n-0.3.0-py3-none-any.whl
| Download URL | pygments_lexer_pseudocode_i18n-0.3.0-py3-none-any.whl |
|---|---|
| Size | 22.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
0a85600236ecf6d74eaaf9b27c17948a66b62dae1901ab0c9ed3b9edc4d45557
|
|
BLAKE2b-256 checksum How to use checksums |
90cb5305b012beda4397df44e1cf6ed8ade74791cb877c0a2d374f49bf1a40e6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.15
|