English
@eightkk/vue-weave / core / fromMermaid
Function: fromMermaid()
fromMermaid(
text,options?):GraphInterchangeImport
Defined in: src/core/interchangeMermaid.ts:742
Read a Mermaid flowchart into NetworkGraph nodes, edges and groups. Pure string parsing without a DOM, done with loops. The text starts with flowchart or graph and an optional direction (TD, TB, LR, RL, BT, returned as direction with TD as TB); %% comment lines, %%{…}%% directives and YAML front matter are skipped. Statements end at a line break or ;. Read: node declarations with the shapes [ ], ( ), { }, (( )), and the other Mermaid delimiters, quoted or unquoted text and @{ shape: …, label: … }; chains (a --> b --> c) and & lists (a & b --> c, every pair); the links -->, ---, -.->, -.-, ==>, === and their longer forms, with o and x ends, < starts, |label| or -- label --> text and id@ edge IDs; and nested subgraph id[title] … end blocks, which become groups. A node belongs to the first subgraph it appears in (or a nested subgraph of it); a later mention in another subgraph is reported (group-member).
Text: " quotes are removed, entity codes (#35;, #quot;) are decoded, and <br> splits a node's label from its detail. Shapes NetworkGraph does not draw become boxes (unsupported-shape); the line style of dotted and thick links is not kept. Ignored with an unsupported-statement warning: classDef, class, :::class, style, click, linkStyle, direction inside subgraphs, accTitle, accDescr, front matter and invisible ~~~ links. Edges to a subgraph are left out (skipped-edge). IDs written by toMermaid in the vw_ form are decoded. Edges get the IDs e1, e2, … unless they have an id@. Positions and sizes are empty.
Throws an Error for a value that is not a string, for another Mermaid diagram type (sequenceDiagram, …), for text without a flowchart header and, with the line and column, for syntax it cannot read and for unbalanced subgraph/end; a RangeError past maxItems.
Parameters
text
string
options?
GraphInterchangeImportOptions = {}