Search code examples
symfonymermaid

Workflow : Dumping mermaid diagrams when Places contain spaces


Summary

I'm creating State machines using the Symfony Workflow Component (v5.4.21 which seems to be the latest 5.4 release) and generating diagrams using the Mermaid dumper.

When places (steps in a workflow) contains spaces, the generated diagram definition is invalid.

Working example

Here's an exemple of a working diagram definition, generated by the dumper :

graph LR
Step10(["Step1"])
Step21(("Step2"))
Step32(("Step3"))
Step10-->|"Goto Step2"|Step21
Step21-->|"Goto Step3"|Step32

And here's the diagram on mermaid.live :

Screenshot of the mermaid.live render

Invalid example

Now, a diagram definition generated from a workflow with places that contain spaces :

graph LR
Step 10(["Step 1"])
Step 21(("Step 2"))
Step 32(("Step 3"))
Step 10-->|"Goto Step2"|Step 21
Step 21-->|"Goto Step3"|Step 32

And here's the error from the mermaid live editor :

Screenshot of the error generated by mermaid.live

What's happening

The dumper doesn't seem to escape the spaces, thus generating invalid mermaid syntax.

I couldn't find anything on the net about this issue, so I preferred to ask here before submitting a bug report (as per the procedure).

It may also not be a bug, and simply a case of me missing some configuration for the dumper.

Thank you for reading !


Solution

  • This was a bug, which has been fixed in Symfony version 5.4.28 (and 6.3.4).

    Updating to 5.4.28 / (6.3.4 if you're on 6.x) should correct the issue.