Mermaid error
Parentheses inside a node label break a flowchart
Reproduced on Mermaid 11.17.2 · Updated
Parentheses inside a node label break a flowchart in Mermaid. The exact parser message, why it happens, and corrected source that renders.
What Mermaid says
Parse error on line 2:
...owchart TD A[Cost (USD)] --> B[Total]
----------------------^
Expecting 'SQE', 'DOUBLECIRCLEEND', 'PE', '-)', 'STADIUMEND', 'SUBROUTINEEND', 'PIPE', 'CYLINDEREND', 'DIAMOND_STOP', 'TAGEND', 'TRAPEND', 'INVTRAPEND', 'UNICODE_TEXT', 'TEXT', 'TAGSTART', got 'PS'Why it happens
Round brackets are shape syntax in a flowchart. Inside an unquoted label, the first bracket is read as the start of a different node shape and the statement falls apart.
The source that fails
flowchart TD
A[Cost (USD)] --> B[Total]How to fix it
Wrap the label in double quotes. Everything between them is treated as text.
flowchart TD
A["Cost (USD)"] --> B[Total]Next steps
Paste your own version into the Mermaid repair tool, which applies this correction and fourteen others and shows every change. The related page covers the surrounding syntax, and the error dictionary lists every message.