Skip to main content

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()
host_presets = engine.supported_host_theme_presets()

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.py
  • src/merman/merman_uniffi.dll on Windows
  • src/merman/libmerman_uniffi.so on Linux
  • src/merman/libmerman_uniffi.dylib on 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

merman-0.7.0-py3-none-win_amd64.whl (8.0 MB view details)

Uploaded Python 3Windows x86-64

merman-0.7.0-py3-none-manylinux_2_35_x86_64.whl (38.9 MB view details)

Uploaded Python 3manylinux: glibc 2.35+ x86-64

merman-0.7.0-py3-none-macosx_11_0_universal2.whl (10.5 MB view details)

Uploaded Python 3macOS 11.0+ universal2 (ARM64, x86-64)

File details

Details for the file merman-0.7.0-py3-none-win_amd64.whl.

File metadata

  • Download URL: merman-0.7.0-py3-none-win_amd64.whl
  • Upload date:
  • Size: 8.0 MB
  • Tags: Python 3, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for merman-0.7.0-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 7b64c567aa3454a058c566915a9f550d9838fbfcb1a7bb434b6c2a7f6ccbdeb1
MD5 7373c2e16ef8b5c00cd09cb365b73f71
BLAKE2b-256 6453c04928cb0493847ac04b05337c0c7768b06e0b844c7a2fb5cabae090db10

See more details on using hashes here.

Provenance

The following attestation bundles were made for merman-0.7.0-py3-none-win_amd64.whl:

Publisher: release-python.yml on Latias94/merman

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file merman-0.7.0-py3-none-manylinux_2_35_x86_64.whl.

File metadata

File hashes

Hashes for merman-0.7.0-py3-none-manylinux_2_35_x86_64.whl
Algorithm Hash digest
SHA256 a1d252294041b1ee254c02c313ece381ea625a48ae0315b744d69029b09c1bd3
MD5 18ac4df6ff8f6c6fbec79ba405d2d6b7
BLAKE2b-256 f5081ac6a136192615459682d9694a90256f13110d5ee40ce401b48978acbe99

See more details on using hashes here.

Provenance

The following attestation bundles were made for merman-0.7.0-py3-none-manylinux_2_35_x86_64.whl:

Publisher: release-python.yml on Latias94/merman

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file merman-0.7.0-py3-none-macosx_11_0_universal2.whl.

File metadata

File hashes

Hashes for merman-0.7.0-py3-none-macosx_11_0_universal2.whl
Algorithm Hash digest
SHA256 5319c6dbed4597030a59fcf02605bcd2275138f52604659877a8efa776380559
MD5 75de0c5694e26cc54fa842a78a2bed32
BLAKE2b-256 88da1999b989cf8643f27ea923f1b4c2c33428b00572c9e66e67823464ca405c

See more details on using hashes here.

Provenance

The following attestation bundles were made for merman-0.7.0-py3-none-macosx_11_0_universal2.whl:

Publisher: release-python.yml on Latias94/merman

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page