marcozaccari / markdown-diagrams-browser-extension

A browser extension for Chrome, Edge, Opera and Firefox that renders markdown diagrams and charts code blocks into preview images.
MIT License
56 stars 27 forks source link

Mermaid flowchart doesn't seem to be supported #7

Open khoadoan91 opened 2 years ago

khoadoan91 commented 2 years ago

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
woja commented 2 years ago

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:

linuxcrash commented 1 year ago

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

The plugin otherwise is very useful!