mermaid-js / mermaid

Generation of diagrams like flowcharts or sequence diagrams from text in a similar manner as markdown
https://mermaid.js.org
MIT License
71.93k stars 6.53k forks source link

The markdown pdf and gh jekyll pages does not render the mermaid blocks. #4364

Closed thatbeautifuldream closed 1 year ago

thatbeautifuldream commented 1 year ago

Description

As you may see the diagram is not generated I've tried changing mermaid server and deploying it to gh pages it has no effect on the same, kindly guide me to fix the error, thanks.

image

Niether the gh pages deployment seems to have render the diagram, I've used the ```mermaid notation to indicate the diagram code

image

Steps to reproduce

Here is the link to my gh pages deployment.

Here is the markdown code

Here is the rendered pdf

Screenshots

No response

Code Sample

No response

Setup

Additional Context

huynhicode commented 1 year ago

Hi @thatbeautifuldream

You can try installing a VS Code extension called, "Markdown Preview Mermaid".

I cloned your repo and have the extension enabled. Was able to view the diagram in the markdown previewer.

Screenshot 2023-05-01 at 9 06 07 AM

thatbeautifuldream commented 1 year ago

Hi @thatbeautifuldream

You can try installing a VS Code extension called, "Markdown Preview Mermaid".

I cloned your repo and have the extension enabled. Was able to view the diagram in the markdown previewer.

Screenshot 2023-05-01 at 9 06 07 AM

Thank you for your reply, i have already tried that but that is not my problem problem is well when markdown-pdf generates the pdf it does not render the mermaid diagrams in the pdf instead it spits out a regular code block.

thatbeautifuldream commented 1 year ago

I have found a hack i may illustrate it here for others stuck in simmilar problem.

npm install -g @mermaid-js/mermaid-cli
mmdc -i readme.md -o readme-out.md

This way I am able to genearate a markdown with diagrams that are rendered just as perfect.

Its just an extra step in my note taking process which i dont mind if there is no solution to it. But if there is do help me out here. Thanks.

aloisklink commented 1 year ago

Hi @thatbeautifuldream, markdown-pdf does not support Mermaid by default, see https://github.com/alanshaw/markdown-pdf/issues/177.

As far as I'm aware, the only tool that might help go from Markdown to PDF is pandoc with a mermaid-filter. But using mermaid-cli like you mentioned is probably the easiest way of doing things!

For your GitHub pages deployment, whatever tool that you're using to convert Markdown to HTML also needs to support Mermaid. For example, if you're using Jekyll, you may want to use the jekyll-spaceship plugin, or just embed the following HTML into your Jekyll templates:

    <script type="module">
      import mermaid from 'https://cdn.jsdelivr.net/npm/mermaid@10/dist/mermaid.esm.min.mjs';
      mermaid.initialize({ startOnLoad: true });
    </script>

There is some generic documentation on how to do this here: https://mermaid.js.org/intro/n00b-gettingStarted.html, but you may want to follow a Jekyll specific guide.


By the way, I'm going to close this issue, since it's not an issue with the Mermaid project, and it's instead an issue with markdown-pdf and jekyll, but feel free to continue to comment here!