mermaid
mermaid copied to clipboard
error in parser when string to parse is \nclassDiagram
Describe the bug I'm using mermaid 9.1.3 through the TiddlyWiki plugin (that I updated to use 9.1.3).
This works:
<$mermaid text='
sequenceDiagram
'/>
It renders an empty sequence diagram
This, however, doesn't:
<$mermaid text='
classDiagram
A <|-- B
'/>
The error is:
Error: Parse error on line 1:
classDiagram A <|
^
Expecting 'statments', 'direction_tb', 'direction_bt', 'direction_rl', 'direction_lr', 'open_directive', 'CLASS_DIAGRAM', got 'NEWLINE'
This works:
<$mermaid text='classDiagram
A <|-- B
'/>
The difference is that the bad code passes '\nclassDiagram..' to the parser while the good one passes 'classDiagram...'. The initial newline is parsed fine for sequence diagrams.
Note also that this doesn't work
<$mermaid text='classDiagram
'/>
With the error
Error: Parse error on line 2:
classDiagram
------------^
Expecting 'direction_tb', 'direction_bt', 'direction_rl', 'direction_lr', 'open_directive', 'acc_title', 'acc_descr', 'acc_descr_multiline_value', 'CLASS', 'ANNOTATION_START', 'MEMBER', 'SEPARATOR', 'CALLBACK', 'LINK', 'CLICK', 'CSSCLASS', 'UNICODE_TEXT', 'NUM', 'ALPHA', 'BQUOTE_STR', got 'EOF'
nor this
<$mermaid text='classDiagram'/>
The error is:
Error: Parse error on line 1:
classDiagram
------------^
Expecting 'NEWLINE', got 'EOF'
passing 'sequenceDiagram' instead of 'classDiagram' in the above creates an empty sequence diagram.
Expected behavior Handle leading and trailing newlines