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

Mermaid flowchart doesn't seem to be supported #7

Open
khoadoan91 opened this issue Jun 23, 2022 · 2 comments
Open

Mermaid flowchart doesn't seem to be supported #7

khoadoan91 opened this issue Jun 23, 2022 · 2 comments

Comments

@khoadoan91
Copy link

khoadoan91 commented Jun 23, 2022

Hi,

It seems the mermaid flowchart isn't supported. I tried to work around by switching from "flowchart" to "graph", but subgraph can't interact with other components. Below is an example that the extension is not able to display. Can you help me check what the issue is?

flowchart TD
    subgraph sub
        direction LR
        a --> c
        b --> c
    end
    1 --> sub
    sub --> 2
    2 -->|info| 3
Loading
@khoadoan91 khoadoan91 changed the title Mermaid flowchart doesn't seem to supported it Mermaid flowchart doesn't seem to be supported Jun 23, 2022
@woja
Copy link

woja commented Jul 5, 2022

I got here by trying to show a git graph - but I think the problem is the same. In my case I needed to remove the %%{init:{ ... from the start of the mermaid, and add a trailing colon : after gitGraph (neither change is required for valid mermaid syntax)


Looking into the code I think the issue is in the recognition of mermaid charts. There is a regex to check for valid charts - and this will not match flowchart:

matchRegex: /^(sequenceDiagram|graph\s+\w{2}|gantt|classDiagram|pie|gitGraph:|erDiagram|journey)\s*\n/,

It will also (unsurprisingly!) not match any of the other new diagram types added since August 2020

2 options would be:

  • find the missing graph types (from mermaid releases) and update the regex
    • this would work until the next new type is added
    • it would not support the %%{init{ unless that was also added to the regex (care should be taken to allow for whitespace / new lines within the above)
  • remove the regex for matching and always assume that a mermaid block may be valid and send it to the service
    • mermaid is robust to errors and this way the extension would show the mermaid error image if the mermaid syntax is invalid
    • this extension would be automatically as up to date with mermaid releases as the kroki.io service

@linuxcrash
Copy link

I have the same problem with the mermaid flowchart diagram. Would it be possible to get this fixed?

The plugin otherwise is very useful!

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

No branches or pull requests

3 participants