markdown-preview.nvim
markdown-preview.nvim copied to clipboard
Rendering mermaid C4 diagrams - parse error
Describe the bug C4 Diagram fails to render. Shows parse error
To Reproduce Steps to reproduce the behavior:
- Go to https://mermaid-js.github.io/mermaid/#/c4c
- Grab sample syntax for C4 context diagram
- Paste into a vimwiki file (surrounded by appropriate
mermaid ....
) - See error.
Parse error on line 1: C4Context ti ^ Expecting 'open_directive', 'NEWLINE', 'SPACE', 'GRAPH', got 'ALPHA'
Expected behavior Other diagram types render correctly. Same syntax renders correctly with mermaid-cli
Desktop (please complete the following information):
- OS: Linux Mint
Same error for the (experimental) mind map example, which is to say that I don't think is specific to C4 diagrams.
Figured it out. This plugin is bundling mermaid in the app/_static/ folder and I think its using an older version that doesn't support C4. They need to update that dependency. I found a workaround though that involves manually downloading and replacing it with the newer mermaid. You need to download mermaid.min.js from the cdn and then replace it in the installed location of markdown-preview. (Note that location may be different if you aren't using packer and that this process would need to be redone every time they push a new version of markdown-preview with the old dependency and you pull and install it I think)
wget 'https://cdn.jsdelivr.net/npm/mermaid@9/dist/mermaid.min.js'
mv mermaid.min.js ~/.local/share/nvim/site/pack/packer/opt/markdown-preview.nvim/app/_static/mermaid.min.js
The same error is thrown for timeline diagrams, @rwyde's fix results in the error changing to "undefined".
The error is fixed using wget 'https://cdn.jsdelivr.net/npm/[email protected]/dist/mermaid.min.js'
.
I got the same error when trying to create a namespace in a class diagram. Using [email protected]
fixed it.