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

Unable to parse class diagram on v10.1.0 #532

Closed
deanpribetic opened this issue May 1, 2023 · 4 comments · Fixed by #536
Closed

Unable to parse class diagram on v10.1.0 #532

deanpribetic opened this issue May 1, 2023 · 4 comments · Fixed by #536
Labels
bug Something isn't working

Comments

@deanpribetic
Copy link

Describe the bug
Unable to parse classes on macOS on 10.1.0. Produces the following error (truncated)

Error: Evaluation failed: Error: Parse error on line 2:
...-v2class Pancake {}class Waffle {}
---------------------^
Expecting 'MEMBER', got 'STRUCT_STOP'
    at pptr://__puppeteer_evaluation_script__:45:17

To Reproduce
Steps to reproduce the behavior:

  1. Make a text file with the following:
classDiagram-v2
    class Pancake {
    }
    class Waffle {
    }
  1. Run via npm mmdc to produce and output. Something like npm mmdc -i example.txt -o output.png

Expected behavior
Expect an image file named output.png to contain two classes Pancake and Waffle.

Desktop (please complete the following information):

  • OS: macOS
  • Browser [e.g. chrome, safari]
  • Version Ventura 13.3.1

Additional context
I have looked into issues #433 and #503 and neither seem to offer anything that helps

@MindaugasLaganeckas
Copy link
Member

Have you seen this https://github.com/mermaid-js/mermaid-cli#install-with-brew?
Try to use docker instead.

@deanpribetic
Copy link
Author

Have you seen this https://github.com/mermaid-js/mermaid-cli#install-with-brew?
Try to use docker instead.

I am using this through npm

@aloisklink aloisklink added the bug Something isn't working label May 3, 2023
@aloisklink
Copy link
Member

Issue confirmed. I've even tested with the Mermaid v10.2.0-rc.2 candidate, and it didn't help.

There has been a bunch of recent updates to class diagrams in Mermaid recently (e.g. mermaid-js/mermaid@ba632ff), so I'm hoping that maybe the soon to be released Mermaid v10.2.0 might fix this issue.

This diagram works fine in https://mermaid.live and on GitHub, so it must be a mermaid-cli issue:

classDiagram-v2
    class Pancake {
    }
    class Waffle {
    }
Loading

@MindaugasLaganeckas
Copy link
Member

Thank you for confirming. Sorry for sleeping.
Hmm. I guess we do not have any Percy tests for class diagrams.
Wonder how can this be mermaid-cli problem?
Let's wait for mermaid v10.2.0

aloisklink added a commit to aloisklink/mermaid-cli that referenced this issue May 4, 2023
Currently, `mermaid-cli` renders mermaid diagrams by:

mmd code → HTML `<div>` contexts → mermaid.run() → HTML `<svg>`

However, when converting the mmd code to HTML `<div>`, newlines and
whitespace formatting may get removed. For the majority of diagrams,
this is no issue, but for some diagrams (e.g. classDiagram), whitespace
does matter.

The mermaid API has a `mermaid.render()` function that we can use
instead, which parses in mmd code directly, without having to go
through a HTML element first:

mmd code →  mermaid.render() →  SVG →  HTML `<svg>`

As an aditional benefit, we get better error messages from Mermaid too!

Fixes: mermaid-js#532
aloisklink added a commit to aloisklink/mermaid-cli that referenced this issue May 4, 2023
Currently, `mermaid-cli` renders mermaid diagrams by:

mmd code → HTML `<div>` contexts → mermaid.run() → HTML `<svg>`

However, when converting the mmd code to HTML `<div>`, newlines and
whitespace formatting may get removed. For the majority of diagrams,
this is no issue, but for some diagrams (e.g. classDiagram), whitespace
does matter.

The mermaid API has a `mermaid.render()` function that we can use
instead, which parses in mmd code directly, without having to go
through a HTML element first:

mmd code →  mermaid.render() →  SVG →  HTML `<svg>`

As an additional benefit, we get better error messages from Mermaid
(they're now proper JavaScript `Error`s!)

Fixes: mermaid-js#532
MindaugasLaganeckas pushed a commit that referenced this issue May 8, 2023
Currently, `mermaid-cli` renders mermaid diagrams by:

mmd code → HTML `<div>` contexts → mermaid.run() → HTML `<svg>`

However, when converting the mmd code to HTML `<div>`, newlines and
whitespace formatting may get removed. For the majority of diagrams,
this is no issue, but for some diagrams (e.g. classDiagram), whitespace
does matter.

The mermaid API has a `mermaid.render()` function that we can use
instead, which parses in mmd code directly, without having to go
through a HTML element first:

mmd code →  mermaid.render() →  SVG →  HTML `<svg>`

As an additional benefit, we get better error messages from Mermaid
(they're now proper JavaScript `Error`s!)

Fixes: #532
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
3 participants