Experimental Python bindings for Merman headless Mermaid rendering.
Project description
merman Python Package
Experimental Python bindings for Merman through UniFFI.
Merman renders Mermaid diagrams without a browser. It can parse Mermaid source, return semantic JSON, compute layout JSON, and render SVG through a headless Rust engine. See the project README, Python binding notes, and diagram coverage status for the main library contract.
API
import merman
engine = merman.MermanEngine()
assert engine.abi_version() == 1
print(engine.package_version())
source = "flowchart TD\nA[Hello] --> B[World]"
svg = engine.render_svg(source, None)
ascii_text = engine.render_ascii(source, None)
semantic_json = engine.parse_json(source, None)
layout_json = engine.layout_json(source, None)
validation = engine.validate(source, None)
diagrams = engine.supported_diagrams()
themes = engine.supported_themes()
try:
engine.render_svg(source, "{")
except merman.MermanError.Binding as error:
print(error.code_name, error.message)
options_json is optional. Pass None for defaults, or a JSON string with parse, layout, and
svg options. The shared schema is documented in
docs/bindings/OPTIONS_JSON.md.
Generate Locally
This directory intentionally does not commit generated binding source or native libraries. Generate
them from a local merman-uniffi cdylib:
cargo build -p merman-uniffi --features bindgen-smoke
cargo run -p merman-uniffi --features bindgen-smoke --example generate_python_package -- \
--package-dir platforms/python/merman
The generator writes:
src/merman/merman_uniffi.pysrc/merman/merman_uniffi.dllon Windowssrc/merman/libmerman_uniffi.soon Linuxsrc/merman/libmerman_uniffi.dylibon macOS
The native library must sit beside the generated module because UniFFI's Python loader resolves the library relative to the generated file.
After generation, a local smoke can import the package by putting src on PYTHONPATH:
PYTHONPATH=platforms/python/merman/src python -c "import merman; print(merman.MermanEngine().render_svg('flowchart TD\nA[Hello]', None)[:4])"
Or run the example script:
PYTHONPATH=platforms/python/merman/src python platforms/python/merman/examples/smoke.py
Build a local platform wheel and run an install smoke:
python3 scripts/build-python-uniffi-wheel.py --run-smoke
The wheel is platform-specific because it bundles merman-uniffi as a native .so, .dylib, or
.dll. Tag releases run release-python.yml, attach platform wheels to the GitHub Release, and
publish the merman distribution to PyPI when Trusted Publishing is configured.
License
This package is dual-licensed under either Apache-2.0 or MIT. See LICENSE for the full license
texts. Mermaid compatibility and upstream Mermaid MIT attribution are documented in
THIRD_PARTY_NOTICES.md.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file merman-0.7.0a2-py3-none-win_amd64.whl.
File metadata
- Download URL: merman-0.7.0a2-py3-none-win_amd64.whl
- Upload date:
- Size: 7.8 MB
- Tags: Python 3, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
643858a65c8bc059440df27d077819a50e9a1e36aa3ba08f0446fc99d01fcbb9
|
|
| MD5 |
4b83c872f937d5599c213b180413867f
|
|
| BLAKE2b-256 |
2d94e4a69129511d8b4caee44d7f6a62f104ca282c011e98b0416fc90db1a760
|
Provenance
The following attestation bundles were made for merman-0.7.0a2-py3-none-win_amd64.whl:
Publisher:
release-python.yml on Latias94/merman
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
merman-0.7.0a2-py3-none-win_amd64.whl -
Subject digest:
643858a65c8bc059440df27d077819a50e9a1e36aa3ba08f0446fc99d01fcbb9 - Sigstore transparency entry: 1754287061
- Sigstore integration time:
-
Permalink:
Latias94/merman@56aec105b09b3ef1cfc2bead025a9c1908c13d82 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/Latias94
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-python.yml@56aec105b09b3ef1cfc2bead025a9c1908c13d82 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file merman-0.7.0a2-py3-none-manylinux_2_35_x86_64.whl.
File metadata
- Download URL: merman-0.7.0a2-py3-none-manylinux_2_35_x86_64.whl
- Upload date:
- Size: 37.8 MB
- Tags: Python 3, manylinux: glibc 2.35+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1276eb6de5bca35b37bff4d4cfa8eee1ef50d47f74463fa3994150ae70df0b7c
|
|
| MD5 |
1322ddf1e55f60c43819589702332a89
|
|
| BLAKE2b-256 |
86f092ba95c50e6c4e84839bc2ed62032e18c0e1dc9df7c87ec7e1355d9c4805
|
Provenance
The following attestation bundles were made for merman-0.7.0a2-py3-none-manylinux_2_35_x86_64.whl:
Publisher:
release-python.yml on Latias94/merman
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
merman-0.7.0a2-py3-none-manylinux_2_35_x86_64.whl -
Subject digest:
1276eb6de5bca35b37bff4d4cfa8eee1ef50d47f74463fa3994150ae70df0b7c - Sigstore transparency entry: 1754287010
- Sigstore integration time:
-
Permalink:
Latias94/merman@56aec105b09b3ef1cfc2bead025a9c1908c13d82 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/Latias94
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-python.yml@56aec105b09b3ef1cfc2bead025a9c1908c13d82 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file merman-0.7.0a2-py3-none-macosx_11_0_universal2.whl.
File metadata
- Download URL: merman-0.7.0a2-py3-none-macosx_11_0_universal2.whl
- Upload date:
- Size: 10.2 MB
- Tags: Python 3, macOS 11.0+ universal2 (ARM64, x86-64)
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7940009475701b3bb95fd7f2c1b12abccafd0494cf36ffc702ceb1c7231a212b
|
|
| MD5 |
4fe4a22e9593fcdddc6f742ff75d09b4
|
|
| BLAKE2b-256 |
32ecfaea34d7ce1ba4435ce55bd6792b0b1e29ad4ee3e699db7d2a1a19a9ade7
|
Provenance
The following attestation bundles were made for merman-0.7.0a2-py3-none-macosx_11_0_universal2.whl:
Publisher:
release-python.yml on Latias94/merman
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
merman-0.7.0a2-py3-none-macosx_11_0_universal2.whl -
Subject digest:
7940009475701b3bb95fd7f2c1b12abccafd0494cf36ffc702ceb1c7231a212b - Sigstore transparency entry: 1754287107
- Sigstore integration time:
-
Permalink:
Latias94/merman@56aec105b09b3ef1cfc2bead025a9c1908c13d82 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/Latias94
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-python.yml@56aec105b09b3ef1cfc2bead025a9c1908c13d82 -
Trigger Event:
workflow_dispatch
-
Statement type: