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, punctuation and # comments.

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

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.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-plum 1.0.0
File Size Uploaded Provenance Actions
pygments_plum-1.0.0.tar.gz 40.2 kB With provenance Details for pygments_plum-1.0.0.tar.gz

Built distribution (wheel)

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

Total release size: 48.3 kB

Release files / pygments_plum-1.0.0.tar.gz

Download URL pygments_plum-1.0.0.tar.gz
Size 40.2 kB
Tags Source
SHA-256 checksum
How to use checksums
e33fefb45e49f69ffd9cab416a8fb64833a32e2d2e465ecf41c1df4ea25d0ad9
BLAKE2b-256 checksum
How to use checksums
7ab58474e5146c0562c402168113d13e8d9b94caa408e5863f0142649d54566b
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.0-py3-none-any.whl

Download URL pygments_plum-1.0.0-py3-none-any.whl
Size 8.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
34427ebebccee29800eb5fb6ae10a2b2d4b3d74ec8807bb5bd30308450b4bb0e
BLAKE2b-256 checksum
How to use checksums
6df43509ef90e84d6f3289fff6cd2f5ec84476d7885502f8d2b5619aea32d9f3
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.0

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.0.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.0 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