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 and .algo files, published on Open VSX and Visual Studio Marketplace
pseudocode-i18n-languageserver gitlab.com/rod2ik/pseudocode-i18n-languageserver Shared LSP intelligence for Kate, Neovim, Spyder and other editor integrations
thonny-pseudocode-i18n gitlab.com/rod2ik/thonny-pseudocode-i18n Thonny 5 adapter using the same LSP intelligence, snippets, navigation and flowcharts

Current version: 0.9.1. Requires: pseudocode-i18n >= 0.9.1, < 0.10.
License: GNU GPL-3.0-or-later.

Highlighting follows the core access-modifier vocabulary: each language keeps its localized public/private/protected aliases while the three English spellings are also recognized universally.

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 or .algo 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:.

0.9.1 — highlighting synchronized with the complete 0.9 language

Version 0.9.1 aligns Pygments with the final 0.9.1 core vocabulary:

  • .pseudo and .algo are equivalent canonical source extensions;
  • all 14 language packs, Unicode identifiers and localized infinitive/imperative aliases are generated from the core;
  • localized and universal-English public / private / protected forms are highlighted consistently;
  • local, alea and entalea are part of the shared vocabulary;
  • a recognized structural head stays colored while a compound statement is incomplete; semantic validity is left to LSP/linter squiggles instead of being encoded as a different syntax color;
  • Pygments remains deliberately syntax-only: type checking, diagnostics, module resolution and execution semantics stay in pseudocode-i18n.

This separation keeps MkDocs and other Pygments consumers visually synchronized with editors without duplicating the parser.

0.9 LSP ecosystem

Version 0.9 aligns the lexer with the shared 0.9 core used by the new language server. Both *.pseudo and *.algo remain canonical source extensions and the lexer continues to derive all syntax vocabulary from pseudocode-i18n.

The shared 0.9 vocabulary also covers the localized local module marker plus universal alea() / entalea(a, b). Structural head keywords remain highlighted while a learner is still typing an incomplete compound statement; validity is communicated by LSP diagnostics/squiggles rather than by removing syntax color.

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.9 core vocabulary directly, including Unicode identifiers, 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.9.1, < 0.10

On a system-managed Python installation where you deliberately use user/system packages:

python -m pip install --break-system-packages pygments-lexer-pseudocode-i18n

Two equivalent source extensions

The current ecosystem uses two strictly equivalent source extensions for every language:

algorithm.pseudo
algorithm.algo

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 or .algo 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/.algo 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/.algo 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.9.1

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.9.1
File Size Uploaded
pygments_lexer_pseudocode_i18n-0.9.1.tar.gz 81.4 kB Details

Built distribution (wheel)

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

Total release size: 108.4 kB

Release files / pygments_lexer_pseudocode_i18n-0.9.1.tar.gz

Download URL pygments_lexer_pseudocode_i18n-0.9.1.tar.gz
Size 81.4 kB
Tags Source
SHA-256 checksum
How to use checksums
5cbd83c8e0a5446aed8cd98dd464f09432867b004f533f63d8b87b639a1cd5ca
BLAKE2b-256 checksum
How to use checksums
24ad9166cc80e6d2c81966ed16cab5f03b0c5f9436c3032d15d7a8c6ecd54ccd
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.9.1-py3-none-any.whl

Download URL pygments_lexer_pseudocode_i18n-0.9.1-py3-none-any.whl
Size 27.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7a2b3dadd79e77c186da4ec9380bc0c4a1c36ecc93ab4ea94623c9bfd6531c39
BLAKE2b-256 checksum
How to use checksums
62632644a10d243c918eaa43851f29b6fb513b9f7b2be57cec7d179fdc0418df
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

This release

0.9.1 This release

2 release files

0.8.5

2 release files

0.8.0

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