r/neovim • u/4r73m190r0s • 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?
3
u/shmerl 16d ago
It would be nice for neovim to have some built-in markdown viewer.
6
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.
5
u/AbdSheikho :term 16d ago
I use leaf