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
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 Distribution
Built Distribution
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 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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f5cc702a41066f7fc260a03557001cba1b0013374a3da34c988f147c5f023b50
|
|
| MD5 |
801cd9f0e8ff0fe16b512df55bdfbb46
|
|
| BLAKE2b-256 |
09a8ab311a65cd6fb2513cb0b8cc18a1ebcdf3f76cea1491e886b8c93a1bcbcb
|
Provenance
The following attestation bundles were made for florajs-0.1.0.tar.gz:
Publisher:
python-publish.yml on topspinj/florajs
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
florajs-0.1.0.tar.gz -
Subject digest:
f5cc702a41066f7fc260a03557001cba1b0013374a3da34c988f147c5f023b50 - Sigstore transparency entry: 2053443780
- Sigstore integration time:
-
Permalink:
topspinj/florajs@1db6807f3a2a44363678bf7cbdc0050422b8a72a -
Branch / Tag:
refs/tags/py-v0.1.0 - Owner: https://github.com/topspinj
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@1db6807f3a2a44363678bf7cbdc0050422b8a72a -
Trigger Event:
push
-
Statement type:
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d6969fb9da36b2662c197912e4d76b59c6b44eebb39c90ffa4021110c5a34c39
|
|
| MD5 |
f95fd396f6f547aab9505e9fda49fc90
|
|
| BLAKE2b-256 |
664213eaa231d3a40aee341d40fcf104858c914f0a958a01428a3ab29470dd61
|
Provenance
The following attestation bundles were made for florajs-0.1.0-py3-none-any.whl:
Publisher:
python-publish.yml on topspinj/florajs
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
florajs-0.1.0-py3-none-any.whl -
Subject digest:
d6969fb9da36b2662c197912e4d76b59c6b44eebb39c90ffa4021110c5a34c39 - Sigstore transparency entry: 2053444716
- Sigstore integration time:
-
Permalink:
topspinj/florajs@1db6807f3a2a44363678bf7cbdc0050422b8a72a -
Branch / Tag:
refs/tags/py-v0.1.0 - Owner: https://github.com/topspinj
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@1db6807f3a2a44363678bf7cbdc0050422b8a72a -
Trigger Event:
push
-
Statement type: