Documentation
¶
Overview ¶
Package flowchart renders Mermaid flowcharts as top-down Unicode box diagrams for terminal display.
Investigation findings are authored in Mermaid (which renders natively on GitHub and in docs), but the terminal renderer (glamour) shows a ```mermaid block as raw source. This package converts a flowchart into boxes and arrows flowing top-to-bottom.
Top-down (rather than left-to-right) layout is used because real investigation diagrams have enough nodes that a horizontal layout overflows any terminal width: flowing downward, width grows only at forks (siblings sit side-by-side), never with chain length. The diagram must be printed OUTSIDE the markdown renderer — glamour word-wraps content and would corrupt the alignment.
The renderer builds a spanning forest from the flowchart's edges: most flows are a chain or a success/failure fork, which render as boxes joined by arrows. Edges that can't be tree edges — back-edges (retry loops), fan-in (two arrows into one node), cross-links — are rendered as "↪" references to the already-shown node, so cyclic and converging diagrams still render instead of falling back. Subgraphs are treated as transparent grouping. It falls back (ok=false) only when the input isn't a flowchart it can parse at all (non-flowchart diagram types, `&` multi-edge shorthand, or unrecognized syntax), so the caller can show the raw Mermaid source.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Segment ¶
Segment is a piece of findings content produced by SplitRenderable: either Markdown to be rendered by the caller's markdown renderer, or a Diagram — a pre-rendered ASCII diagram that must be printed verbatim (NOT through the markdown renderer, which would word-wrap and corrupt its alignment). Exactly one field is non-empty.
func SplitRenderable ¶
SplitRenderable splits findings markdown into segments, replacing each ```mermaid block that is a renderable flowchart with a Diagram segment. Blocks it cannot render are left inside the surrounding Markdown segment, so the raw Mermaid survives for the markdown renderer (and for GitHub/doc rendering).