Is it possible to convert Mermaid script to XML(mxGraphModel), so that components in the Mermaid diagram can be customized in Draw.io?

1.3k views Asked by At

Mermaid allows us to draft and edit diagrams in markdown-styled code, and Draw.io (or Diagrams.net) is able to import Mermaid script, which is however treated as a standalone object after import. The Mermaid script can be modified, but the components of the Mermaid diagram cannot be broken down to be edited individually in Draw.io.

Would that be possible if the Mermaid script could be converted and imported as XML(mxGraphModel), or via any other formats?
It would be convenient to load existing Mermaid diagram and then tailor it in Draw.io for more dedicated diagramming needs.

Similar idea has been suggested in mermaidjs/mermaid.cli, and I am seeking if there are any existing tool or solution for this.

1

There are 1 answers

0
Michael Kay On

Looks to me like a job for Invisible XML, which basically allows you to convert anything to XML if you can write a BNF grammar for it. However, writing a BNF grammar for Mermaid looks a little bit tricky because it seems to be very informally specified - the section on syntax seems to give lots of examples but no actual grammar, unless I missed something.

Once you've got it in XML, of course, it's easy to convert it do DotML using XSLT, and then you've got the power of GraphViz at your fingertips. Or you could convert it to anything else that has an XML representation.