Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

error in parser when string to parse is \nclassDiagram #3243

Closed
ittayd opened this issue Jul 19, 2022 · 2 comments · Fixed by #4534
Closed

error in parser when string to parse is \nclassDiagram #3243

ittayd opened this issue Jul 19, 2022 · 2 comments · Fixed by #4534
Assignees
Labels
Graph: Class Status: Approved Is ready to be worked on Type: Bug / Error Something isn't working or is incorrect

Comments

@ittayd
Copy link

ittayd commented Jul 19, 2022

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

@ittayd ittayd added Status: Triage Needs to be verified, categorized, etc Type: Bug / Error Something isn't working or is incorrect labels Jul 19, 2022
@knsv
Copy link
Collaborator

knsv commented Aug 20, 2022

I think there is some characters picked up by the plugin as I can not reproduce the issue. Neither in the live editor or a local html file.

@knsv
Copy link
Collaborator

knsv commented Aug 20, 2022

Added a unit test and could reproduce the issue that way. We will plan a fix.

@knsv knsv removed the Status: Triage Needs to be verified, categorized, etc label Aug 20, 2022
sidharthv96 added a commit that referenced this issue Aug 21, 2022
* develop:
  Fix #3009 Update main
  #3243 Adding disabled testcase for diagram with leading \n
@jgreywolf jgreywolf self-assigned this Mar 17, 2023
@jgreywolf jgreywolf added Status: Approved Is ready to be worked on Graph: Class labels Mar 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Graph: Class Status: Approved Is ready to be worked on Type: Bug / Error Something isn't working or is incorrect
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants