1.3.4 • Published 2 years ago

@lifeomic/mermaid-simple-flowchart-parser v1.3.4

Weekly downloads
-
License
UNLICENSED
Repository
github
Last release
2 years ago

mermaid-simple-flowchart-parser

Parse a subset of mermaid flowchart markdown syntax to JSON Graph.

Install

yarn add @lifeomic/mermaid-simple-flowchart-parser

Usage

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.

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',
      },
    ],
  }
} */

Limitations

This is a subset of mermaid flowchart syntax. It is meant to handle only the following:

  • %% Comments - comments in code
  • flowchart - 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
1.3.4

2 years ago

1.2.0

2 years ago

1.3.3

2 years ago

1.3.2

2 years ago

1.3.1

2 years ago

1.3.0

2 years ago

1.1.7

2 years ago

1.1.6

2 years ago

1.1.5

2 years ago

1.1.4

2 years ago

1.1.3

2 years ago

1.1.2

2 years ago

1.1.1

2 years ago

1.1.0

2 years ago

1.0.2

2 years ago