markdown-preview.nvim icon indicating copy to clipboard operation
markdown-preview.nvim copied to clipboard

Rendering mermaid C4 diagrams - parse error

Open sliptonic opened this issue 2 years ago • 4 comments

Describe the bug C4 Diagram fails to render. Shows parse error

To Reproduce Steps to reproduce the behavior:

  1. Go to https://mermaid-js.github.io/mermaid/#/c4c
  2. Grab sample syntax for C4 context diagram
  3. Paste into a vimwiki file (surrounded by appropriate mermaid .... )
  4. 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

sliptonic avatar Oct 28 '22 14:10 sliptonic

Same error for the (experimental) mind map example, which is to say that I don't think is specific to C4 diagrams.

AphonicChaos avatar Nov 13 '22 08:11 AphonicChaos

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

rwyde avatar Feb 09 '23 16:02 rwyde

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'.

sh-cau avatar Apr 28 '23 09:04 sh-cau

I got the same error when trying to create a namespace in a class diagram. Using [email protected] fixed it.

christoph-blessing avatar Jun 07 '23 12:06 christoph-blessing