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()

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.0a2-py3-none-win_amd64.whl (7.8 MB view details)

Uploaded Python 3Windows x86-64

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

Uploaded Python 3manylinux: glibc 2.35+ x86-64

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

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

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

Hashes for merman-0.7.0a2-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 643858a65c8bc059440df27d077819a50e9a1e36aa3ba08f0446fc99d01fcbb9
MD5 4b83c872f937d5599c213b180413867f
BLAKE2b-256 2d94e4a69129511d8b4caee44d7f6a62f104ca282c011e98b0416fc90db1a760

See more details on using hashes here.

Provenance

The following attestation bundles were made for merman-0.7.0a2-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.0a2-py3-none-manylinux_2_35_x86_64.whl.

File metadata

File hashes

Hashes for merman-0.7.0a2-py3-none-manylinux_2_35_x86_64.whl
Algorithm Hash digest
SHA256 1276eb6de5bca35b37bff4d4cfa8eee1ef50d47f74463fa3994150ae70df0b7c
MD5 1322ddf1e55f60c43819589702332a89
BLAKE2b-256 86f092ba95c50e6c4e84839bc2ed62032e18c0e1dc9df7c87ec7e1355d9c4805

See more details on using hashes here.

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

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.0a2-py3-none-macosx_11_0_universal2.whl.

File metadata

File hashes

Hashes for merman-0.7.0a2-py3-none-macosx_11_0_universal2.whl
Algorithm Hash digest
SHA256 7940009475701b3bb95fd7f2c1b12abccafd0494cf36ffc702ceb1c7231a212b
MD5 4fe4a22e9593fcdddc6f742ff75d09b4
BLAKE2b-256 32ecfaea34d7ce1ba4435ce55bd6792b0b1e29ad4ee3e699db7d2a1a19a9ade7

See more details on using hashes here.

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

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