Skip to main content

Beautiful, interactive diagrams from Mermaid-compatible syntax — Python interface to the Flora JS library

Project description

florajs

Beautiful, interactive diagrams from Mermaid-compatible syntax — the Python interface to Flora.

  • Jupyter-native: diagrams display interactively (zoom, pan, hover highlighting, click links) right in the notebook.
  • Headless SVG export: to_svg() runs the Flora renderer in an embedded V8 engine — no browser, no Node.js.
  • Two ways in: a programmatic builder, or raw Flora/Mermaid syntax.
pip install florajs

Quick start

from florajs import Flowchart

fc = Flowchart("LR", theme="tufte")
fc.node("raw", "Raw events", shape="cylinder")
fc.node("clean", "Cleaned", shape="stadium")
fc.edge("raw", "clean", "dbt run")
fc  # displays interactively in Jupyter

Or from raw Flora/Mermaid syntax:

from florajs import Diagram

d = Diagram("""
flowchart TD
  a[Start] --> b{Decide}
  b -->|yes| c([Done])
  b -->|no| a
""", theme="sketch")
d.to_svg_file("decision.svg")

Building diagrams

fc = Flowchart("TD")                       # TB | TD | BT | LR | RL

fc.node("a", "Label", shape="diamond")     # rect | rounded | circle | diamond
                                           # stadium | cylinder | queue
fc.edge("a", "b", "maybe",                 # optional edge label
        style="dotted",                    # solid | dotted | thick
        arrow="bidirectional")             # arrow | open | bidirectional

with fc.subgraph("Ingest"):                # groups nest
    fc.node("api", "API")
    fc.node("queue", "Queue", shape="queue")

fc.link("api", "https://example.com/api",  # click-through links
        tooltip="API docs", target="_blank")

Every builder method chains: fc.node("a").edge("a", "b").

Rendering

Method Output
to_svg() SVG string (headless, no browser needed)
to_svg_file(path) SVG file
to_html() standalone interactive HTML document
to_html_file(path) standalone interactive HTML file
_repr_html_ automatic interactive display in Jupyter
source the generated Flora syntax
warnings parser diagnostics

Themes

Presets: default, tufte, digital, sketch. Or pass a dict of theme overrides:

Diagram(src, theme={"background": "#0b1021", "fontSize": 13})

Errors you can trust

Flora never renders silently wrong output. Lines that cannot be parsed are skipped and reported as a FloraSyntaxWarning; pass strict=True to raise FloraParseError instead:

Diagram(src, strict=True).to_svg()  # raises FloraParseError on any skipped line

Development

The package embeds a JS bundle built from the repository root:

npm run build:python        # builds and vendors flora.iife.js
cd python
pip install -e ".[dev]"
pytest

Project details


Download files

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

Source Distribution

florajs-0.1.0.tar.gz (41.4 kB view details)

Uploaded Source

Built Distribution

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

florajs-0.1.0-py3-none-any.whl (41.1 kB view details)

Uploaded Python 3

File details

Details for the file florajs-0.1.0.tar.gz.

File metadata

  • Download URL: florajs-0.1.0.tar.gz
  • Upload date:
  • Size: 41.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for florajs-0.1.0.tar.gz
Algorithm Hash digest
SHA256 f5cc702a41066f7fc260a03557001cba1b0013374a3da34c988f147c5f023b50
MD5 801cd9f0e8ff0fe16b512df55bdfbb46
BLAKE2b-256 09a8ab311a65cd6fb2513cb0b8cc18a1ebcdf3f76cea1491e886b8c93a1bcbcb

See more details on using hashes here.

Provenance

The following attestation bundles were made for florajs-0.1.0.tar.gz:

Publisher: python-publish.yml on topspinj/florajs

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

File details

Details for the file florajs-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: florajs-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 41.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for florajs-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d6969fb9da36b2662c197912e4d76b59c6b44eebb39c90ffa4021110c5a34c39
MD5 f95fd396f6f547aab9505e9fda49fc90
BLAKE2b-256 664213eaa231d3a40aee341d40fcf104858c914f0a958a01428a3ab29470dd61

See more details on using hashes here.

Provenance

The following attestation bundles were made for florajs-0.1.0-py3-none-any.whl:

Publisher: python-publish.yml on topspinj/florajs

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