vscode-markdown-pdf icon indicating copy to clipboard operation
vscode-markdown-pdf copied to clipboard

[BUG] Mermaid Diagrams Not Rendered in Exported PDF

Open emmett08 opened this issue 1 year ago • 9 comments

Description: When attempting to export a Markdown file containing Mermaid diagrams to PDF using the "Markdown PDF" extension in VSCode, the resulting PDF does not render the Mermaid diagrams. Instead, it displays the raw Mermaid code.

Reproduction Steps:

  1. Create or open a Markdown file (.md) containing a fenced code block with the mermaid language identifier.
    graph TD;
        A-->B;
        A-->C;
        B-->D;
        C-->D;
    
  2. Execute the command Markdown PDF: Export (pdf) from the VSCode command palette.
  3. Review the exported PDF.

Expected Behaviour: The PDF should display a rendered Mermaid diagram corresponding to the code in the Markdown file.

Actual Behaviour: The PDF displays the raw Mermaid code instead of the rendered diagram.

emmett08 avatar Oct 25 '23 07:10 emmett08

Link to https://github.com/yzane/vscode-markdown-pdf/issues/337

emmett08 avatar Oct 25 '23 07:10 emmett08

I found changing the mermaid server to "https://cdn.jsdelivr.net/npm/[email protected]/dist/mermaid.min.js" worked to fix the issue.

cajun-code avatar Jan 05 '24 19:01 cajun-code

I had other issues with every mermaid 10.x release. Some failed to render completely, some had syntax errors. Mermaid v10 had a number of breaking changes, so maybe that is the reason for the problems. I switched to https://unpkg.com/[email protected]/dist/mermaid.min.js which is the most recent v9 release and everything seems to work well.

cabal95 avatar Jan 19 '24 16:01 cabal95

I had other issues with every mermaid 10.x release. Some failed to render completely, some had syntax errors. Mermaid v10 had a number of breaking changes, so maybe that is the reason for the problems. I switched to https://unpkg.com/[email protected]/dist/mermaid.min.js which is the most recent v9 release and everything seems to work well.

Thanks, only this version worked for me.

sanurielf avatar Jan 24 '24 16:01 sanurielf

Same for me! Mermaid v9.4.3 is also working on my end. EDIT: In VS code, you have to edit the markdown-pdf.mermaidServer setting.

thewingit avatar Feb 20 '24 16:02 thewingit

unfortunately, neither the default, nor 10.4.0, nor 9.4.3 server renders my sequence diagram, which is displayed fine in preview with Markdown Preview Mermaid Support extension.

  • the default one (latest?) just shows mermaid code as is
  • 9.4.3 and 10.4.0 show the image with message about syntax or graph error

P.S. there is logging in the source code, but I didn't see any log files at %USERPROFILE%\.vscode\extensions\yzane.markdown-pdf-1.5.0. excuse me for noob's question (never coded extensions for VS Code), where to find the logs just to help all of us with troubleshooting?

megaromb avatar Mar 14 '24 19:03 megaromb

Running into a similar problem here, my erDiagrams are not rendering in either 9.4.3 or 10.4.0.

hobbes1069 avatar Apr 05 '24 12:04 hobbes1069

I found changing the mermaid server to "https://cdn.jsdelivr.net/npm/[email protected]/dist/mermaid.min.js" worked to fix the issue.

As of today, this solution worked for me. Thanks

muhammad-mobeen avatar Aug 19 '24 07:08 muhammad-mobeen

It works, but seems like it's only working for 'mature' components. block-beta is working in Markdown Preview, but not in PDF export.

With https://cdn.jsdelivr.net/npm/[email protected]/dist/mermaid.min.js (and 10.7) and https://cdn.jsdelivr.net/npm/[email protected]/dist/mermaid.min.js" the output is Screenshot 2024-08-24 at 14 57 40

RobinHeitz avatar Aug 24 '24 13:08 RobinHeitz