Skip to content

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

@erdemuncuoglu

Description

@erdemuncuoglu

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions