Incorrect cardinality symbol in erDiagram parser
Author: denilsonsaCreated Jun 3, 2026Updated Aug 29, 2026
According to https://mermaid.js.org/syntax/entityRelationshipDiagram.html#relationship-syntax These are the valid symbols:
| Value (left) | Value (right) | Meaning |
|---|---|---|
|o |
o| |
Zero or one |
|| |
|| |
Exactly one |
}o |
o{ |
Zero or more |
}| |
|{ |
One or more |
But the parser is somehow not recognizing them correctly.
Look at this example:
erDiagram
foo {
}
fuzz {
}
bar {
}
baz {
}
a {
}
b {
}
c {
}
d {
}
foo }o--|| bar : "should work"
foo }|--|| baz : "should work"
a }|--|{ b : "should work"
b }o--o{ c : "should work"
c ||--|| d : "should work"Renders in GitHub as:
erDiagram
foo {
}
fuzz {
}
bar {
}
baz {
}
a {
}
b {
}
c {
}
d {
}
foo }o--|| bar : "should work"
foo }|--|| baz : "should work"
a }|--|{ b : "should work"
b }o--o{ c : "should work"
c ||--|| d : "should work"
And beautiful-mermaid renders as:
If I add these two invalid lines (because the curly brace is pointing to the wrong side):
fuzz {o--|| bar : "should not work"
fuzz {|--|| baz : "should not work"Then both GitHub and mermaid.live throw an error, but beautiful-mermaid incorrectly renders them:
I only explored the errors in the left cardinality symbol. I have not explored if the right symbol also has trouble, and I'll leave this as an exercise for the reader.
Source: lukilabs/beautiful-mermaid