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

When a requirement contains "-class" in name, it breaks the mermaid graph. #16

Open
erdemuncuoglu opened this issue May 3, 2023 · 1 comment

Comments

@erdemuncuoglu
Copy link

erdemuncuoglu commented May 3, 2023

When a requirement contains "-class" in name, it breaks the mermaid graph and in output html it shows

Syntax error in graph
mermaid version 8.6.0

This happens after version 1.4.0. In version 1.3.2 it works.

Below is a sample composer.json to reproduce this issue.

{
  "name": "test/issue",
  "description": "Composer Graph Issue",
  "require": {
    "php": ">=8.1",
    "php-curl-class/php-curl-class": "9.14.3"
  }
}

Generated mermaid code snipped from output html.

graph LR;
test__issue == ">=8.1" ==> PHP;
php_curl_class__php_curl_class-->ext_curl;
php_curl_class__php_curl_class-->|">=7.0"|PHP;
test__issue == "9.14.3" ==> php_curl_class__php_curl_class;

subgraph "Your Package"
    test__issue("test/issue");
end
subgraph "Required"
    php_curl_class__php_curl_class("php-curl-class/[email protected]");
end
subgraph "PHP Platform"
    PHP("[email protected]");
    ext_curl("ext-curl");
end

Error response from Mermaid Live Editor.

Error: Parse error on line 3:
...url_class__php_curl_class-->ext_curl;
-----------------------^
Expecting 'SEMI', 'NEWLINE', 'SPACE', 'EOF', 'SQS', 'AMP', 'STYLE_SEPARATOR', 'DOUBLECIRCLESTART', 'PS', '(-', 'STADIUMSTART', 'SUBROUTINESTART', 'VERTEX_WITH_PROPS_START', 'ALPHA', 'COLON', 'CYLINDERSTART', 'DIAMOND_START', 'TAGEND', 'TRAPSTART', 'INVTRAPSTART', 'START_LINK', 'LINK', 'DOWN', 'DEFAULT', 'NUM', 'COMMA', 'MINUS', 'BRKT', 'DOT', 'PUNCTUATION', 'UNICODE_TEXT', 'PLUS', 'EQUALS', 'MULT', 'UNDERSCORE', got 'CLASS'

I don't know the internals of mermaid so I don't have any clue why ..._class is tried to be parsed as a symbol class but just for the curiosity changing all occurrences to something like ..._classs successfully shows the diagram (Mermaid Live Editor)

@SmetDenis
Copy link
Member

Thank you for finding the issue.
I think I know how to fix it.

Just these days I'm going to do a release of the new major version.
I will add this fix to the release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants