JBZoo/Composer-Graph

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

erdemuncuoglu opened this issue · 1 comments

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/php-curl-class@9.14.3");
end
subgraph "PHP Platform"
    PHP("PHP@8.1.18");
    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)

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.