Docs

Mermaid

Draw flowcharts and sequence diagrams from a code fence.

Open Markdown

Write a mermaid fence and the block is marked for diagram rendering instead of syntax highlighting.

content/pipeline.mdx
```mermaid
flowchart LR
  MD[Markdown] --> C[compile]
  C --> R[static Rust registry]
  R --> H[HTML]
```

Configuring it

build.rs
use proa_docs_build::{Config, MermaidConfig};

let config = Config::new().source(source.markdown(pipeline.mermaid(MermaidConfig::new())));
OptionMeaning
enabledTurn Mermaid handling on
code_fencesTreat ```mermaid fences as diagrams
rendererRecorded for a future renderer; the emitted markup is the same for every value today
fallbackWhat to show when rendering does not happen

The build emits the diagram source in a hidden data-proa-docs-mermaid-source block and an empty output slot in data-proa-docs-mermaid-output, then leaves rendering to a script you ship.

proa_docs does not currently ship a Mermaid renderer. The build emits the source and the slot; supplying a renderer is yours. Until you do, the figure is blank with scripting on, and the <noscript> fallback appears only when JavaScript is disabled.

Diagram or picture?

Mermaid is right for anything with a decision or a sequence — it lives in git, needs no design time, and survives refactoring. For a conceptual diagram where the layout is the explanation, a hand-authored SVG beats Mermaid's auto-layout every time.

Code block · Math · Configuration

Search

Type at least 2 characters