-
Hi, Is there a way to pre-render diagrams i wrote in md? Thats quite illogical to use live render of diagrams on static site which is designed to be fast. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
Hi @skorphil you are asking a perfectly legitimate question. The essential answer is: in theory yes, that is a contradiction with the principle of a static website; but in practice, the javascript library works for all cases.... I know it's a little paradoxical, but in several cases, a dynamic diagram IS what is wanted (hyperlinks, dynamic effects depending on theme, etc.). if you pre-render a diagram as an image, it is static: it will look "dead". Also:
But if you are OK with a static diagram, by all means an image would work. Doing that is a little more complicated than it seems, since you are going to store those images somewhere. Then, if you want to use gif or jpeg, you will have to define a resolution (svg would be better). How would you calculate the proper size and resolution of your diagram? It might be possible to make svg diagrams responsive, but it's a little tricky. I have thought several times about doing that; but each time, I gave up because there was no compelling reason to do so, because the javascript library was already doing an honest job for my use case. I would consider going that route (optionally of course) if there was really a compelling use case, where the javascript library does not work. I never happened so far, though. |
Beta Was this translation helpful? Give feedback.
-
Note that you can do a manual pre-rendering outside of mkdocs, with the [mermaid javascript client](mmdc -i readme.template.md -o readme.md). According to the website: mmdc -i readme.template.md -o readme.md |
Beta Was this translation helpful? Give feedback.
Hi @skorphil you are asking a perfectly legitimate question.
The essential answer is: in theory yes, that is a contradiction with the principle of a static website; but in practice, the javascript library works for all cases....
I know it's a little paradoxical, but in several cases, a dynamic diagram IS what is wanted (hyperlinks, dynamic effects depending on theme, etc.). if you pre-render a diagram as an image, it is static: it will look "dead".
Also:
mdkocs-serve
and your webbrowser as an instant visualizer, you are g…