Documentation
¶
Overview ¶
Package mermaid renders Mermaid diagram text (flowchart, sequence, state, class, er) as Unicode box-drawing art for terminals. It is a faithful port of the npm module grok-mermaid 0.2.2 (Apache-2.0).
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Art ¶
Art is a rendered diagram. Plain[i] and Styled[i] describe the same row: Plain is right-trimmed for display width and copy/paste, Styled keeps the run structure needed to colour it.
Width is the display columns the widest row needs — the number to compare against the space you have. It cannot be recovered from Plain, whose rows are strings of code points, not columns.
Warnings lists source the flowchart grammar could not read and dropped. Non-empty means the art is real but incomplete. Only flowcharts warn; the other grammars refuse the whole diagram instead, and Render returns nil. They are advisory: do not gate rendering on them.
func Render ¶
Render renders a Mermaid source block as Unicode box-drawing art.
Supported: `graph`/`flowchart` (including `subgraph`), `stateDiagram`, `classDiagram`, `erDiagram` and `sequenceDiagram`.
The diagram is laid out at whatever size it needs; Art.Width reports the columns that turned out to be. Deciding what to do when that exceeds the space at hand is the caller's.
nil means there is no art to show: blank input, a syntax error, a diagram type this renderer does not draw, or one large enough that laying it out is refused.
Rendering is best-effort. A flowchart keeps whatever parsed; the stricter grammars additionally get one retry without their final line, which is what keeps a streaming diagram on screen while its last statement is half-typed. Everything given up on is listed in Art.Warnings — advisory only, never a reason to withhold the art.