fix: error mermaid.parse on invalid shapes

Currently, invalid shapes cause an error when rendering, but not when
parsing. This confuses the Mermaid Live Editor, e.g. by not showing the
error message.

Instead, I've added an `isValidShape()` that validates if the shape is
valid at parse time. This only checks shapes using the new extended
shapes syntax. Currenlty, using `A(-this is an ellipse node-)` is broken
(see #5976) and also causes an invalid shape error at render time, but
I've ignored it in this PR, so it will continue pass at parse-time
(we have unit tests checking ellipse parsing).

See: https://github.com/mermaid-js/mermaid/issues/5976
This commit is contained in:
Alois Klink
2024-10-18 19:36:08 +09:00
parent 17e2f9e0d4
commit 5fabd414fb
7 changed files with 42 additions and 10 deletions

View File

@@ -0,0 +1,5 @@
---
'mermaid': patch
---
fix: error `mermaid.parse` on an invalid shape, so that it matches the errors thrown by `mermaid.render`