{diagram}
Draws a flowchart or a sequence diagram from Mermaid-style lines of text, laid out on the server as inline SVG.
Syntax
{diagram direction='LR', edges='curved', title='text'} A[Start] --> B{Ready?} {/diagram}
{diagram type='sequence', title='text'} Shop ->> Bank: Charge {/diagram}
Options
-
type -
flowchart(default) orsequence- a first linesequenceDiagramsays so too. -
direction -
TB(default),BT,LRorRL- else a first linegraph LRorflowchart LRnames it. -
edges -
How a flowchart's edges run:
orthogonal(default, rounded turns),straightorcurved. -
title -
The accessible name, default
FlowchartorSequence diagram.
Description
{diagram} turns a few lines of text in its content into a picture, written the way Mermaid writes them, and lays it out on the server (tags/_lib/diagram.php) as inline SVG - no JavaScript in the browser. The content is taken as it stands before the level walks it, so the braces of a decision like B{Paid?} need no ignore.
Flowcharts
A line is a chain of nodes and edges. Nodes: A[Box], B(Rounded), C([Stadium]), D{Decision?}, E((Circle)), F[(Database)], G{{Hexagon}} - a node is named once with its text and later by its id alone. Edges: --> (arrow), --- (line), -.-> and -.- (dashed), ==> and === (thick), a label as -->|text| or -- text -->; & joins several nodes on one side (A & B --> C) and %% starts a comment. The layout is layered, with as few crossings as it can find; direction turns it, edges chooses how the lines run.
Sequence diagrams
With type='sequence': participant A as Alice, actor U, messages ->> (arrow), -->> (dashed), -> and --> (no head), -x (cross), -) (open), Note left of A: text (also right of and over A,B), the frames loop, alt / else, opt, par / and, critical and break closed by end, and autonumber.
The SVG has role="img", a <title> and a <desc> that says every edge or message. A diagram without nodes answers nothing, so its @else@ shows; a line it cannot read, or an unknown type, direction or edges, is an error under the strict check.
Examples
A flowchart
Nodes of several shapes, labelled edges and a dashed loop back.
{diagram title='Handling an order'}
A([Order placed]) --> B{In stock?}
B -->|no| C[Order from supplier]
C -.->|delivered| B
B -->|yes| D[Take payment] --> E[(Orders database)] --> F((Shipped))
{/diagram}
Left to right, curved
direction=LR and edges=curved; & fans one node out to several.
{diagram direction='LR', edges='curved', title='Deploy pipeline'}
code([Commit]) --> build[Build]
build --> unit[Tests] & lint[Lint]
unit & lint --> gate{Green?}
gate -->|yes| live((Live))
gate -.->|no| code
{/diagram}
A sequence diagram
Participants, numbered messages, dashed replies, an alt frame and a note.
{diagram type='sequence', title='Paying an order'}
participant S as Shop
participant B as Bank
autonumber
S ->> B: Charge 42.00
alt Enough funds
B -->> S: Approved
else Declined
B -->> S: Refused
end
Note over S,B: The card number never reaches the shop
{/diagram}
See also
- {chart} Draws a chart as inline SVG on the server - 46 kinds, from bars and lines to sankeys, maps of a hierarchy and org charts.
- {timeline} Draws events on a time axis as inline SVG - cards above and below the axis, spans as bars, or one under the other.