Parses Mermaid definitions into mermaid svg diagram.
npm i mermaid-parse
yarn add mermaid-parse
import mermaidParse from 'mermaid-parse';
const definition = `
graph TD
A[Christmas] -->|Get money| B(Go shopping)
B --> C{Let me think}
C -->|One| D[Laptop]
C -->|Two| E[iPhone]
C -->|Three| F
`;
mermaidParse(definition, { extension: 'png' }).then(htmlRes => {
res.send(htmlRes);
});
Currently supported configurations:
option | type | description | default |
---|---|---|---|
extension? | "svg" | "png" |
The output extension | svg |
This package uses Mermaid-js to transform the definition to svg diagram in HTML string format.
If you want to know how the definition is composed please read mermaid-js documentation.
This version does not support theming and other customization. Instead, it uses mermaid defaults. There are plans to support further configurations in the future.
The intended use for this package is to transform diagrams in node backend service and return it as a response.
MIT