Built a native Mermaid renderer in Rust, would love feedback #7322
OlaProeis
started this conversation in
Show and tell
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hey all,
I've been working on Ferrite, an open source Markdown editor in Rust, and ended up building a native Mermaid renderer for it. No JS, no webview, just parsing the syntax and drawing with egui. Figured this community would be the right place to share it and get some feedback.
Flowcharts are where I've put the most work. Directions, node shapes, subgraphs, edge labels, classDef/linkStyle all work reasonably well. Sequence diagrams are decent too - participants, different arrow types, activation boxes, notes, the loop/alt/opt blocks.
Pie charts are simple so those just work. State diagrams, class diagrams, ER diagrams, mindmaps, gantt, timeline, journey maps - they all render but I haven't implemented everything for each type.
I should be honest about what doesn't work though. Git graphs render vertically instead of horizontally like Mermaid does, which looks weird. Sankey, XY charts, quadrant diagrams aren't supported at all. And edge cases will trip it up - complex nesting, unusual syntax variations, some of the newer features. It's really meant for "normal" diagrams you'd find in documentation, not pushing the limits of what Mermaid can do.
The motivation was wanting instant rendering without spinning up a JS runtime. Works offline, renders fast, but the tradeoff is definitely less compatibility.
One thing I'm planning is to extract the renderer as a standalone Rust crate so other projects can use it. Right now it's tied to Ferrite but the parsing and layout logic could work with different rendering backends (SVG, PNG, etc). Not sure if that's interesting to anyone here but figured I'd mention it.
Anyway, a couple things I wanted to ask:
Would this be appropriate for the community integrations list? I don't want to overstate what it does but figured it might be useful for people who want native rendering and are ok with the limitations.
Also if anyone wants to try it and tell me which of their diagrams break, that would actually be really helpful. Real-world mermaid files are way better for testing than stuff I make up.
https://github.com/OlaProeis/Ferrite (~800 stars, MIT licensed)
https://getferrite.dev
The renderer code is in
src/markdown/mermaid/if anyone's curious about the implementation.Beta Was this translation helpful? Give feedback.
All reactions