Docs / Write a diagram
Mermaid
Draw a Mermaid flowchart you already have, and see what changes.
open-diagram lays the flowchart out again, with the same measuring and checks as any other diagram:
open-diagram draw signup_flow.mmd
It reads flowchart and graph in any direction, nodes of any bracket shape, chains, &, edge labels, and front-matter titles. Dotted edges (-.->) become planned connections. Each top-level subgraph becomes a shaded group with its own band, so groups never cover other nodes. A class named like a state (A:::building, or class A,B planned) sets that state. Lines that skip a step or point backwards travel above or below the picture. From Python, use from_mermaid(text). The example is examples/signup_flow.mmd.
What carries over
flowchartandgraph, withLR,TDorTB.- Nodes in any bracket shape, with or without quotes.
- Chains (
A --> B --> C) and&(A & B --> C). - Line labels:
-->|text|,-- text -->,-. text .->and== text ==>. - Dotted lines (
-.->) become connections still to build, drawn dotted. - Each top-level
subgraph…endbecomes a shaded group. - A class named after a state sets that state:
A:::buildingorclass A,B planned. The states are live, building, trial, planned and retiring. - A
title:in the front matter. Without one the title is “Flowchart”, and--titlesets it. %%comments, and;between statements.
What changes
- Every node is drawn as the same box. Diamonds, circles and other shapes are not kept.
<br/>becomes a space, so a label written on several lines is drawn as one line, wrapped to fit.- Thick lines (
==>), lines with no arrowhead (---), circle and cross ends (--o,--x) and two-way arrows (<-->) are all drawn as ordinary one-way arrows. RLis drawn left to right, andBTtop to bottom.- A subgraph inside another subgraph is merged into the outer one.
- Class names that are not states are ignored, and so are styling lines:
classDef,style,linkStyle,clickanddirection. - Markdown strings and icons such as
fa:fa-carare shown exactly as typed. - open-diagram chooses the layout. Boxes go in steps by their longest path, and lines that skip a step or point backwards run in a lane above or below the picture.
What it does not read
- Other Mermaid diagram types, such as
sequenceDiagram. The command stops and names the line. - The newer shape syntax,
A@{ shape: … }. The command stops and names the node. - D2 files. open-diagram has no D2 reader.