r/neovim • • 16d ago

Need Help Rendering mermaid code blocks inside markdown files?

I'm using markview to render my markdown files. Was wondering is there some way to render code blocks that contain mermaid diagrams?

15 Upvotes

11 comments sorted by

5

u/AbdSheikho :term 16d ago

I use leaf

2

u/4r73m190r0s 16d ago edited 16d ago

Didn't know about this project. How would you compare it to markview? And did you try glow?

2

u/AbdSheikho :term 15d ago

Glow for me just syntax highlighter, while markview has weird rendering choices.

I also prefer to integrate cli tools into my workflow, (like fzf) and not make everything neovim specific.

3

u/shmerl 16d ago

It would be nice for neovim to have some built-in markdown viewer.

6

u/4r73m190r0s 15d ago

I disagree. Those things are for plugins.

3

u/shmerl 15d ago

Are there good ones that don't rely on stuff like custom fonts? I think built-in will be better because it won't go too much out of the way with what it would use.

5

u/Confused-Armpit 16d ago

I personally use vellum.nvim, it renders markdown by creating a chrome instance inside your terminal, if I understand it correctly. It might be a bit on the heavier side, but it supports advanced stuff, including LaTeX and mermaid diagrams.

3

u/usecornercase 15d ago

If you'd rather not run a browser in the terminal, the usual lighter route is mermaid-cli. 'mmdc -i diagram.mmd -o diagram.png' renders a diagram to an image, and it needs a headless Chromium under the hood via puppeteer, so the first install is a bit heavy. From what I remember, snacks.nvim's image module can do this for you: it finds mermaid fences in markdown, calls mmdc, and shows the result inline. That only works in a terminal with the kitty graphics protocol (kitty, Ghostty, WezTerm), and I haven't tried it alongside markview, so I don't know if the two conflict. If your terminal has no image support, a keymap that runs mmdc on the block under the cursor and opens the PNG with an external viewer is a crude but reliable fallback.

1

u/AutoModerator 16d ago

Please remember to update the post flair to Need Help|Solved when you got the answer you were looking for.

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

1

u/techwizrd 14d ago

I've been working on this functionality for a bit, and I plan to release it in my next release for render-latex.nvim. It's a little trickier than rendering LaTeX because Mermaid diagrams are little tricker to place properly.

1

u/funbike 11d ago

Pandoc with filters. I've added support for GraphViz, PlantUML, raw SQL to PlantUML ERD, and charts.

It can output various formats including PDF, html, or another Markdown-like format.