Expand description
Render Mermaid diagrams to SVG in pure Rust.
Supported diagram types: pie, sequence, flowchart, state, class, ER, gantt, journey, timeline, sankey, quadrantChart, xychart, radar, packet, mindmap, gitGraph, requirementDiagram, C4 (Context/Container/Component/ Dynamic/Deployment), block, architecture, kanban, treemap, zenuml.
let svg = mermaid_svg::render("pie\n\"A\" : 1\n\"B\" : 2\n").unwrap();
assert!(svg.starts_with("<svg"));§Gallery
Reference output for every supported diagram type, rendered by this crate
from the sources in
samples/
(regenerate with cargo run --example gen-doc-diagrams).
§Pie
Modules§
- ast
- AST types shared by all diagram kinds.
Structs§
- Diagram
Meta - Shared, diagram-agnostic metadata extracted from the source preamble
(YAML frontmatter,
%%{init}%%directives, andaccTitle/accDescrstatements) before dispatching to a per-diagram parser. - Theme
Enums§
- Diagram
- Parse
Error - Render
Error - Syntax
Kind - The class of a
ParseError::Syntaxfailure. Lets callers distinguish the recurring kinds of parse error (unknown statement vs bad number vs unclosed block) without inspecting the free-formmessage.
Functions§
- parse
- parse_
with_ meta - Parse
input, also returning the cross-cuttingDiagramMeta(title,accTitle/accDescr, theme) extracted from the source preamble. The diagram body is parsed from the source with the preamble removed. - render
- render_
diagram - render_
diagram_ with - render_
with