This release is a pre-release and may not be stable for production use.
pygments-beancount
A Pygments lexer for Beancount ledgers.
Install it, and ```beancount code blocks highlight in Sphinx and MyST, MkDocs and Pelican, pygmentize, and every other tool that highlights code with Pygments.
There is nothing to configure: Pygments finds the lexer through its plugin entry point.
Features
- Covers the full Beancount v3 syntax: every directive, flags, postings, costs (
{},{{}},{502.12 # 9.95 USD}), prices, tolerances, arithmetic, metadata, tags, links,pushtagandpushmeta, org-mode headings and ignored lines. - Its token patterns follow Beancount's own scanner,
lexer.l. - Never emits an
Errortoken: snippets with placeholders such as...still highlight, and Sphinx never drops a block's colours. - Uses only standard token types, so every Pygments style colours it.
- Depends on Pygments only; it never imports Beancount.
Installation
The package needs Python 3.11 or later and Pygments 2.13 or later.
pip install pygments-beancount
With uv, add it to the dependency group that builds your documentation:
uv add --group docs pygments-beancount
Do not install it together with the older, unmaintained beancount-pygments-lexer: both register the beancount alias, so which one Pygments uses depends on the order it finds their entry points.
Usage
In Sphinx with MyST
Install the package in the environment that builds the documentation, then use beancount (or bean) as the language of a code block.
No change to conf.py is needed.
```beancount
2026-01-05 * "Employer" "Salary for January" #payroll
Assets:Bank:Checking 4,250.00 USD
Income:Salary
```
Directives work too, with all their options:
```{literalinclude} ledger/main.beancount
:language: beancount
:lines: 1-20
```
In MkDocs and other Python-Markdown sites
Python-Markdown highlights through Pygments with the codehilite or pymdownx.highlight extension.
Pelican enables codehilite by default, and Material for MkDocs highlights through pymdownx.highlight, so in both ```beancount blocks highlight once the package is installed.
The default mkdocs theme uses highlight.js instead; the Markdown guide shows how to switch it to Pygments.
Hugo, Zola and browser-side highlighters do not use Pygments, so the package has no effect there.
On the command line
pygmentize -l beancount -f terminal256 main.beancount
pygmentize -f html -O full -o main.html main.beancount
From Python
from pygments import highlight
from pygments.formatters import HtmlFormatter
from pygments_beancount import BeancountLexer
html = highlight('2026-01-01 open Assets:Cash USD\n', BeancountLexer(), HtmlFormatter())
Documentation
The full documentation, including the token reference and how-to guides, is at https://ericof.github.io/pygments-beancount/.
Development
The project uses uv and a Makefile:
make install # create the virtualenv
make check # ruff, mypy --strict and pytest
make docs # build the documentation; warnings are errors
See the contributing guide for the rest.
License
BSD 2-Clause, the same licence as Pygments. See LICENSE.
Metadata
Release files for pygments-beancount 1.0.0a1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pygments_beancount-1.0.0a1.tar.gz | 19.8 kB | With provenance | Details for pygments_beancount-1.0.0a1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pygments_beancount-1.0.0a1-py3-none-any.whl | Python 3 | none | any | Details for pygments_beancount-1.0.0a1-py3-none-any.whl |
Total release size: 28.1 kB
Release files / pygments_beancount-1.0.0a1.tar.gz
| Download URL | pygments_beancount-1.0.0a1.tar.gz |
|---|---|
| Size | 19.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
257f61aaf288c8ba0e1a23d7f28b32950525970ed9e9eba883c43804353d12e7
|
|
BLAKE2b-256 checksum How to use checksums |
109acb04cf897f9b15cd78c102d2429ac34a2b06d2c0a9c32736cd8652e74a1a
|
| 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 23, 2026.
Transparency logRelease files / pygments_beancount-1.0.0a1-py3-none-any.whl
| Download URL | pygments_beancount-1.0.0a1-py3-none-any.whl |
|---|---|
| Size | 8.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
4bd6f39df17e86edaec8c5c35a2e172d50b724faac29130df6eb3543648d5d2f
|
|
BLAKE2b-256 checksum How to use checksums |
34674487a7fb922c3d0210c55cb3b822795c5bdf96d52af7fa46d6057ddbba4a
|
| 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 23, 2026.
Transparency logSecurity for pygments-beancount 1.0.0a1
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.
Attestation for pygments_beancount-1.0.0a1.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 23, 2026.
Transparency logA 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.