Parse mermaid flowchart text to JSON Graph
npm install @lifeomic/mermaid-simple-flowchart-parserParse a subset of mermaid flowchart markdown syntax to
JSON Graph.
```
yarn add @lifeomic/mermaid-simple-flowchart-parser
Only one function, parseString is exported. You pass a string containing
mermaid flowchart information. The function will return JSON Graph data or raise
an error.
`typescript
import { parseString } from '@lifeomic/mermaid-simple-flowchart-parser';
const chart =
flowchart
start
--> call1("data.debug, arg1: a, arg2: b,c");
const graph = parseString(chart);
/*
graph = {
graph: {
directed: true,
nodes: {
call1: {
label: 'data.debug',
metadata: {
action: 'data.debug',
params: {
arg1: 'a',
arg2: 'b,c'
},
},
},
on_start: {
label: 'start',
},
},
edges: [
{
directed: true,
source: 'on_start',
target: 'call1',
},
],
}
} */
`
This is a subset of mermaid flowchart syntax. It is meant to handle only the
following:
- %% Comments - comments in codeflowchart
- - start of flowchart (required)id
- - bare node definitions (for start and error)id("xxx")
- - action nodes with possible parameters-->
- - edges between nodes (note this is the only edge supported)-- Comment -->
- and -->|comment|` - edge comments are ignored, but will
display in mermaid