Expand description
§rusty-mermaid
Mermaid diagram rendering in pure Rust.
The base crate parses mermaid syntax and produces a Scene — a backend-agnostic
intermediate representation of primitives (rects, paths, text, etc.).
Enable features to add rendering backends:
| Feature | What you get |
|---|---|
svg | to_svg() → SVG string |
raster | to_png() → PNG bytes |
wgpu | vello/WebGPU scene builder |
gpui | gpui canvas element (Zed) |
viewport | Pan/zoom state + coordinate transforms |
Structs§
- BBox
- Axis-aligned bounding box.
xandyare the center coordinates (matching dagre’s convention). - Color
- RGBA color.
- Parse
Error - A parse error with location information.
- Point
- 2D point in layout coordinate space.
- Scene
- Backend-agnostic drawing output. The contract between layout and rendering.
- Style
- Visual style for shapes and paths.
- Text
Style - Text styling properties.
- Theme
- Diagram color theme. All rendering reads from this — no hardcoded values.
Enums§
- Diagram
Kind - Supported diagram types.
- Direction
- Layout direction for ranked graphs.
- Primitive
- A single drawing element. All backends (SVG, raster, gpui, wgpu, PDF) consume these.
- Text
Anchor - Text horizontal alignment.
Functions§
- detect
- Detect the diagram type from the first non-empty, non-comment line.
- render
- Parse and render a mermaid diagram to a
Scene. - render_
to_ scene - Unified entry: parse + layout → Scene.