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
71.07k stars 6.4k forks source link

Nested subgraph with 'end;' causes entire image not to render #2138

Open LordAro opened 3 years ago

LordAro commented 3 years ago

Describe the bug

As far as I can tell from the documentation, semicolons are supposed to be entirely optional. That's a bit too JS-like for me, so I like to use them to separate statements anyway.

If I nest subgraphs and have an end; statement within the subgraph, the graph does not render. There are no (relevant) parse/syntax errors on the console. I've used flowchart here, but graph exhibits the same behaviour.

To Reproduce Minimal test case:

flowchart
subgraph cluster0;
  subgraph cluster1;
    B;
  end; %% <-- remove this semicolon
end;

Expected behavior image renders properly without errors

Screenshots Expected output:

Code Sample See above.

Desktop (please complete the following information):

Additional context Reproduced with Mermaid versions 8.9.2 & 8.10.2

nirname commented 1 year ago

https://github.com/mermaid-js/mermaid/blob/develop/packages/mermaid/src/dagre-wrapper/mermaid-graphlib.js#L440