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
68.69k stars 6.07k forks source link

'Graph' keyword in mindmap diagram breaks if elk renderer set for flowchart #5507

Closed varon closed 1 week ago

varon commented 1 month ago

Description

This error was really incomprehensible to diagnose.

Setting the elk renderer in the mermaid config for flowchart breaks mindmaps escaping somehow.

This works correctly:

%%{init: {'flowchart': {'defaultRenderer': 'elk'}}}%%
 mindmap
   ("single item mindmap")
    ["Descendant node"]

This is broken (note this is ONLY set for flowchart):

%%{init: {'flowchart': {'defaultRenderer': 'elk'}}}%%
 mindmap
   ("single item mindmap")
    ["Descendant node in graph"]

but this works:

 mindmap
   ("single item mindmap")
    ["Descendant node in graph"]

How? why?

Examples on GitHub of broken diagrams

This works - where we don't use the keyword graph inside the string label:

%%{init: {'flowchart': {'defaultRenderer': 'elk'}}}%%
 mindmap
   ("single item mindmap")
    ["Descendant node"]

This is broken:

%%{init: {'flowchart': {'defaultRenderer': 'elk'}}}%%
 mindmap
   ("single item mindmap")
    ["Descendant node in graph"]

Setup

varon commented 1 month ago

This is a glaring bug impacting us. Please address or explain what we need to do move forward here.

nirname commented 1 week ago

Thanks for reaching out & sorry for the long response, things are piling up.

Nothing too complex. Because of the wrong detector it thinks that you are trying to invoke flowchart-elk diagram.

But I understand how it looks from the outside.

%%{init: {'flowchart': {'defaultRenderer': 'elk'}}}%%
 mindmap
   ("single item mindmap")
    ["Descendant node in my image"]

That's a bug for sure.