mermaid-js / mermaid

Generation of diagrams like flowcharts or sequence diagrams from text in a similar manner as markdown
https://mermaid.js.org
MIT License
72.83k stars 6.66k forks source link

Using Mermaid to generate SVG outside the DOM #1923

Open yankeeinlondon opened 3 years ago

yankeeinlondon commented 3 years ago

I would like to be able to convert textual mermaid instructions into the appropriate HTML (aka, mainly SVG but also interior DIV elements) using the Mermaid API but it seems as if the examples all use the render() method and that this actually reaches into the browser's document object. In my situation I would not have access to the DOM and was hoping I could use the API to just generate the markup.

Is this possible? Are there any examples you can point me to? I did think at first maybe I could use the lower level render() function to achieve this goal but so far I've not had success.

p.s. keep up the awesome work on this project ... it is something I tell every one of my developer friends about and it is a great contribution to the data-visualization space.

knsv commented 3 years ago

You can do just that but Mermaid in itself uses the browser so I am not sure if this will help you. You can look at some code from our rendering tests as an example of using the API though and try it out: https://github.com/mermaid-js/mermaid/blob/develop/cypress/platform/bundle-test.js