Skip to main content

Plumlang for Pygments

A Pygments lexer plugin for Plumlang, for .plum files. Once it is installed, everything that highlights code with Pygments knows Plumlang: Sphinx, MkDocs (Material included), pygmentize, Jupyter, and the many static site generators and chat tools built on Pygments.

It highlights:

  • Keywords: declarations (plant, root, branch, tree, trait, kind), seed imports with their module paths and aliases, control flow, and/or/not/in/is/as, and the constants good, bad and none.
  • Names at declarations: functions and methods after branch, trees, traits and kinds after their keyword, constants after root.
  • Types and built-ins: int, str, list, map, ...; the built-in functions (drop, ask, len, ...); conversions such as int(text); the built-in error trees (ValueError, IOError, ...); self and super.
  • Strings with escapes (\n, \{, \u{1F351}) and {interpolation}, whose expression is highlighted like any other code, with format specs ({total:.2}, {n:>5}); """ strings across lines.
  • Numbers in every form (1_000, 0xFF, 0o755, 0b1010, 6.022e23), operators and punctuation.
  • Comments: # lines (Comment.Single), #[ ... ]# block comments, nested and across lines (Comment.Multiline), and ## doc comments (String.Doc, as Pygments' Rust and Nim lexers have them).

The rules follow the reference lexer in plumlang/plumlang. The lexer never produces Pygments' Error token: code the compiler would reject (&&, a 'single-quoted' string, a bad escape) is still highlighted sensibly.

Install

pip install pygments-plum

The package registers itself with Pygments through the pygments.lexers entry point, so nothing else needs configuring. Check it with:

pygmentize -L lexers | grep -A1 Plumlang

Use

The lexer's names are plum and plumlang; it is picked for *.plum files and the text/x-plum MIME type.

On the command line

pygmentize -l plum hello.plum                 # to the terminal
pygmentize -l plum -f terminal256 -O style=monokai hello.plum
pygmentize -l plum -f html -O full -o hello.html hello.plum
pygmentize hello.plum                         # picked by the .plum suffix

In Sphinx

Add pygments-plum to your docs' requirements (for example docs/requirements.txt on Read the Docs), then write:

.. code-block:: plum

   plant name = "Ada"
   drop("Hello, {name}!")

or, with MyST Markdown, a ```plum fence.

In MkDocs

With pymdownx.highlight and pymdownx.superfences (Material for MkDocs turns them on in its recommended setup), add pygments-plum to the requirements your docs are built with and use ```plum fences:

# mkdocs.yml
markdown_extensions:
  - pymdownx.highlight:
      use_pygments: true
  - pymdownx.superfences
```plum
tree Account {
    owner: str
    balance: float = 0.0

    branch to_str() -> str => "{self.owner}: {self.balance:.2}"
}
```

From Python

from pygments import highlight
from pygments.formatters import HtmlFormatter
from pygments.lexers import get_lexer_by_name

html = highlight('drop("Hello, {name}!")', get_lexer_by_name("plum"), HtmlFormatter())

from pygments_plum import PlumLexer works too.

Development

python -m venv .venv
.venv/bin/pip install -e '.[test]'
.venv/bin/pytest

The tests lex every program in tests/examples/ (a copy of Plumlang's examples and language tests), checking that no Error token appears and that the tokens put back together give the input unchanged, then check the tokens of keywords, strings, interpolation, numbers and comments one by one, and that Pygments finds the lexer through its entry point. To run the first test over a full Plumlang checkout as well, point PLUM_SOURCE at it:

PLUM_SOURCE=../plumlang .venv/bin/pytest

tests/test_sample.py checks the lexer against Plumlang's shared highlighting sample (tests/highlight/, downloaded from main, or the folder in PLUM_HIGHLIGHT): every keyword in the lexer is a keyword here, sample.plum has no Error token and round-trips, and, with plum installed, every token plum tokens reports has the right type. CI runs it on every push and weekly, so a keyword added to Plumlang fails here until the lexer knows it.

PLUM_HIGHLIGHT=../plumlang/tests/highlight .venv/bin/pytest tests/test_sample.py

Licence

The code in this repository is under the MIT licence. The Plumlang name and logo are trademarks of Elixpo and are not licensed by it; see NOTICE.

Metadata

Release files for pygments-plum 1.0.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-plum 1.0.1
File Size Uploaded Provenance Actions
pygments_plum-1.0.1.tar.gz 42.8 kB With provenance Details for pygments_plum-1.0.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pygments-plum 1.0.1
File Interpreter ABI Platform Actions
pygments_plum-1.0.1-py3-none-any.whl Python 3 none any Details for pygments_plum-1.0.1-py3-none-any.whl

Total release size: 51.3 kB

Release files / pygments_plum-1.0.1.tar.gz

Download URL pygments_plum-1.0.1.tar.gz
Size 42.8 kB
Tags Source
SHA-256 checksum
How to use checksums
7889da6c03929e11f97c2c3538f752d74e9c7d5e2a57a3b46c2c8a108b6ec9d8
BLAKE2b-256 checksum
How to use checksums
3b6982f495f0c0b6768418e3cdae18ffab9785a5d0a561eb7595e78dbe61001f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 24, 2026.

Transparency log

Release files / pygments_plum-1.0.1-py3-none-any.whl

Download URL pygments_plum-1.0.1-py3-none-any.whl
Size 8.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
31b9d33fc5b29c7de52e82a02b4a6c18d571f11da0e00db7a9d7467ebebbb0b9
BLAKE2b-256 checksum
How to use checksums
063dbb3c79affd568b2c0bf1b32c8eafb1f640ba0cfef2cd0686c20e2d9f9822
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 24, 2026.

Transparency log

Security for pygments-plum 1.0.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for pygments_plum-1.0.1.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 24, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.0.1 This release

2 release files Full provenance

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