Skip to main content

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-i18n gitlab.com/rod2ik/vscode-pseudocode-i18n VS Code editing experience for .pseudo files, published on Open VSX and Visual Studio Marketplace

Current version: 0.8.0. Requires: pseudocode-i18n >= 0.8.0, < 0.9.
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, Dutch, Danish, Swedish, Norwegian, Finnish, Greek, Ukrainian, Russian or English. The generic pseudocode lexer detects the source language automatically, understands the same # language: xx override as the core (language/lang, optional colon), 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.

All four forms below are equivalent; the first is canonical:

# language: fr
# language fr
# lang: fr
# lang fr

# is the only comment/directive marker. // is integer division. In pseudocode.config.yml, lang: is also accepted as an alias for language:.

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, Fin and optional specific end markers;
  • Pour, Tant Que, Répéter N fois and Répéter ... Jusqu'à;
  • infinitive/imperative command synonyms such as Afficher / Affiche, Lire / Lis, Mostrar / Muestra, German Ausgeben / Gib aus, and their localized equivalents;
  • 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.

Current highlighting contract

The lexer follows the 0.7 core vocabulary directly, including typed callable signatures and the localized object model. Semantic linting remains intentionally in pseudocode-i18n; this package is syntax highlighting only. It includes:

  • Début/algorithm, process/subprocess and translated forms;
  • localized no-fall-through switch/case (Selon, Cas, Autrement, ...);
  • infinitive/second-person imperative aliases for action verbs, including repeat;
  • no-newline output and clear-screen built-ins;
  • //, %, ^, **, <>, != and localized MOD/logical operators;
  • localized imports plus universal Python import, from, as;
  • localized and universal Python-style built-in functions/constants such as sqrt, abs, len, pow and pi;
  • # comments only.

Multi-word import aliases such as French En tant que are highlighted contextually on import lines, so common grammar words such as tant and que remain normal structural keywords elsewhere.

Install

python -m pip install pygments-lexer-pseudocode-i18n

The core dependency is installed automatically:

pseudocode-i18n >= 0.8.0, < 0.9

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

The current ecosystem uses one source extension for every language:

algorithm.pseudo

Language-bearing filename extensions such as .pseudo-fr, .pseudo-es and .pseudocode-fr are not part of the 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 directive (`language`/`lang`, optional colon) > 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

Usage is generated separately for all 14 languages in the project order: French, Spanish, Italian, Portuguese, German, Dutch, Danish, Swedish, Norwegian, Finnish, Greek, Ukrainian, Russian, 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 directive (# language: xx canonically; language/lang, optional colon), 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.

0.8 Unicode, 14 languages and compact TeX

The generic and explicit lexers are now generated for 14 languages, including Greek and Cyrillic-language pseudocode. Identifiers are Unicode-aware rather than limited to Latin ranges. Language-specific lexer entry points remain generated from the core registry.

Token.Pseudocode.Math now recognizes the compact safe TeX subset used by the MkDocs renderer, including common symbols, \displaystyle, \frac, \dfrac and \sqrt. Renderers may opt into simple power fragments using ^ or **; the default standalone lexer keeps those as ordinary pseudocode operators.

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-i18n — VS Code / Open VSX editing support for .pseudo files.

The documentation for this lexer is published at rod2ik.gitlab.io/pygments-lexer-pseudocode-i18n.

Compound localized type aliases are matched as complete aliases: French n-uplet is highlighted as a type without making n or uplet reserved identifiers; the same rule applies to multi-word aliases such as German Reelle Zahl.

Release files for pygments-lexer-pseudocode-i18n 0.8.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pygments-lexer-pseudocode-i18n 0.8.0
File Size Uploaded
pygments_lexer_pseudocode_i18n-0.8.0.tar.gz 79.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pygments-lexer-pseudocode-i18n 0.8.0
File Interpreter ABI Platform
pygments_lexer_pseudocode_i18n-0.8.0-py3-none-any.whl Python 3 none any Details

Total release size: 105.2 kB

Release files / pygments_lexer_pseudocode_i18n-0.8.0.tar.gz

Download URL pygments_lexer_pseudocode_i18n-0.8.0.tar.gz
Size 79.1 kB
Tags Source
SHA-256 checksum
How to use checksums
ee7906b90a8a985c993b322172ef520ec5488e9185c86959eb2826c982f3b30f
BLAKE2b-256 checksum
How to use checksums
7067f70b642e2c1868bb87d1899f00f8a3de215739d0a225ab1dcb030c12c8c6
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.8.0-py3-none-any.whl

Download URL pygments_lexer_pseudocode_i18n-0.8.0-py3-none-any.whl
Size 26.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a6c6e786792955aa08071a64c0641c67265e842b66e7518b849fdf1cadb5404a
BLAKE2b-256 checksum
How to use checksums
e16323bb7e2afdff2b9c1d30f9ca21081600af91b3bdec0f9f7422c8e8c2d806
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.15

Release history Release notifications | RSS feed

0.9.12

2 release files

0.9.9

2 release files

0.9.8

2 release files

0.9.7

2 release files

0.9.6

2 release files

0.9.5

2 release files

0.9.1

2 release files

0.8.5

2 release files

This release

0.8.0 This release

2 release files

0.7.0

2 release files

0.6.1

2 release files

0.6.0

2 release files

0.5.1

2 release files

0.5.0

2 release files

0.4.0

2 release files

0.3.2

2 release files

0.3.1

2 release files

0.3.0

2 release files

0.2.0

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page