// In a document: markdown = { version = "0.2.18", features = ["mermaid"] }
// On its own:
let drawing = mermaid::render("flowchart LR\n A --> B", &mermaid::Options::default(), &Fonts)?;
std::fs::write("flow.svg", &drawing.svg)?;
struct Fonts;
impl mermaid::Host for Fonts {
fn width(&self, text: &str, size: f64, style: u8) -> f64 { /* … */ }
fn icon(&self, name: &str) -> Option<String> { None } // optional
}- In a document, the fence draws off the main thread and keeps the diagram it last drew until the next is ready, or stands empty. Source that does not draw shows as code with the error under it.
Host::widthmust answer as the fonts the SVG is shown in.mermaid::Metricsanswers with Arial's advances and has no icons.- The SVG is Pele 1.6.0's, with class names, CSS variables and ids prefixed
bezel; it does not match mermaid.js's. For a renderer without CSS custom properties, setOptions::colors. bezel-mermaidbuilds without gpui, forwasm32-unknown-unknowntoo.