Pele – Mermaid diagrams as themeable SVG

(pele.run)

489 points | by dchest a day ago ago

45 comments

  • neomantra 33 minutes ago

    This was pretty inspiring -- I have been working on file format rendering for a pager in terminal+browser and totally forgot about Mermaid!

    Much of the work uses SVG as an intermediary so this Pele pattern works great. OP is a TypeScript project, seems great for that ecosystem.

    Searching found this go-mermaid library [1] that operates similarly with SVG its target. We have a Golang TUI picture/SVG widget and a Golang WASM/browser embedder, so I just forked it and had an LLM add a live Mermaid/SVG demo using them [2]. The demo is intended for go-mermaid so it uses its rasterizer, composited to our widget.

    (took <15 minutes since I had worked similarly just days ago and had the components at the ready, plus could point at Pele; these LLMs are ridiculous at forging from patterns)

    Cool thing is that same visual experience can be had in a terminal if it supports Kitty graphics protocol.

    [1] https://github.com/zkrebbekx/go-mermaid

    [2] https://neomantra.github.io/go-mermaid/

  • lukeify 18 hours ago

    Anytime I try mermaid for anything more complex than a toy diagram I always end up absolutely frustrated by the arcane and topologically poor layout that is produced.

    Styling seems like a trivial problem by comparison.

    • kepano 17 hours ago

      I strongly agree, and that's why I designed Pele to only follow its syntax not its layout. See the examples https://pele.run/examples

      The playground also has a Compare mode https://pele.run/playground

      • DenisM 14 hours ago

        The layout quality is very impressive!

        Have you given much thought to diffing diagrams? The source can be version controlled and a source diff can be seen, but a visual diff would be amazing and easily sway me from writing prose to writing diagrams.

      • nkmnz 3 hours ago

        I've tested a couple of diagrams that I found on some website and I couldn't see any major differences in the layout. Can you point to some systematic differences?

      • CrimsonRain 14 hours ago

        Could you not make Pele part of Marmaid or they wont accept a contribution like this?

        • blazarquasar 7 hours ago

          To quote another reply regarding mermaid by @kepano:

          > Mermaid.js has transitioned to "mermaid.ai" and is losing its original vision. Take a look at their new site.

          > The latest version of Mermaid (12.1) ships with yet another layout engine (three now), and has a questionable safety record (see CVEs). In Obsidian 1.13 we had to introduce a new toggle/warning because of potential unsafe Mermaid diagrams.

          https://x.com/kepano/status/2111575190081847776

    • ferroman 6 hours ago

      Then you may like tool I use https://ferroman.github.io/diagc/

    • jd3 7 hours ago

      I don't even bother writing mermaid by hand when I'm making decision trees. Instead of visualizing it using PrecisionTree in excel (I just use that for the actual data modeling), I've been first modeling the tree in plaintext, then pipe it through claude with a previous tree I've made as reference. I then ask it to use the content of the current tree and match it to the style of the previous one.

    • kylepomykala 10 hours ago

      I have the same issue. A neat trick is to have it so the large language model creates an HTML file with what you need inside of it too. That allows for even more flexibility.

    • tptacek 17 hours ago

      Graph layout is a famously hard problem!

      • mcapodici 15 hours ago

        I wonder if it is almost like writing. In that to make the diagram that communicates well you need to have solved the problem properly.

        • alfiedotwtf 13 hours ago

          A common layout implementation is to provide constraints to a SAT Solver… so you were close :)

          • wongarsu 22 minutes ago

            To my taste, most automatic layout implementations produce horrible layouts. Yes, you can use SAT-solve and optimize your way towards a node ordering that produces no crossing lines, but those rarely create something that makes intuitive sense of the content

            Good layout is a lot more like writing, in that you have to think about how the intended recipient will perceive and what you want them to notice in which order, and how to make it easy to follow the various relationships

      • thegagne 15 hours ago

        I have had good luck with D2 and elk or dagre. If you get into the nitty gritty of elk you can do a _lot_ with it.

        • jeffreygoesto 8 hours ago

          If only it had a good documentation. I really like the elkjs JavaScript version (thanks, Ulf!) bitte unfortunately transcoding makes transferring the Java docs even harder...

        • jhoechtl 10 hours ago

          The tala layout engine for d2 is now included it provides a very good layout.

    • giancarlostoro 17 hours ago

      I kinda just shove what I want out of it to literally any basic model from the frontier labs, I usually dont need anything super fancy, but it does the job, even color coded regions for me (which is fancier than I usually do) and then I can shove that into Lucid since it can render them.

  • vb-startr 25 minutes ago

    Nice work...will try to incorporate it in our tools and projects. Dark mode support is a good highlight. I appreciate this work. Please keep it up.

  • Ancapistani 11 hours ago

    > A flowchart subgraph keeps its own direction even when it links to nodes outside the subgraph.

    This, in and of itself, is sufficient reason for me to switch, even if it were slower than Mermaid.js.

    I’ve not even made it through the list yet and I’m sold.

  • dkga 9 hours ago

    Brazilian me thought it was an homage to Pelé. I’m glad the text explains the name.

  • 9dev 4 hours ago

    Amazing. I just migrated the diagrams on the docs site of a project of mine, and they just look great[0]. Before, I had a combination of mermaid, panzoom, and some minor workarounds to get integrated styling and dark theme work right. Pele not only takes care of all of that, but also manages a nicer layout!

    [0] https://cetacean.mazetti.me/authentication#oidc

  • nickmain 20 hours ago

    Does the official Mermaid library still require a full or headless browser environment in order to lay out the SVG? If so, Pele is great news for embedding Mermaid rendering in other places.

    • falsaberN1 16 hours ago

      There is also Merman on Github that outputs a SVG.

      https://github.com/Latias94/merman

    • invokestatic 18 hours ago

      The python mermaidx library works for this, which works well for generating documentation with embedded diagrams as part of CI/CD but the layout/rendering can sometimes be very wonky. For instance I will have a bunch of connections crossing over each other instead of neatly arranged to avoid it. Changing the layout settings does not fix it so sometimes I will just export it from mmdc and embed a png.

  • haburka 7 hours ago

    Thank goodness. Theming mermaid and using it server side is such a nightmare. I had many issues trying to get it to work competently with CSS variables for dark mode / light dark. This seems way better.

  • Imustaskforhelp 20 hours ago

    Is pele open source?

    I tried to find the source code of it but I was unable in finding so

    Edit: found it, https://github.com/obsidianmd/pele

    Also folks, this is a good reminder to please have a github icon on the top of the page to easily show git/github links if the app is open source, also helps in the fact that I can star your projects and bookmark them more easily :-D

  • druvisc 19 hours ago

    Just FYI, "pele" is "mouse" in Latvian. :)

  • kinduff 15 hours ago

    Noting that the mermaid preview in the playground is broken.

  • shellerik 13 hours ago

    The examples are not very dark-mode friendly

  • syngrog66 6 hours ago

    longtime user of GraphViz for that kind of use case but I have a TODO to try programmatic generation of my next software diagram in Inkscape's XML format.

  • dbg31415 15 hours ago

    Tools like this are so amazing because they allow Claude to edit and draw and save to a single markdown file. So practical! Version control friendly. People can use them, sure. Buy AI can really take off with tools like this.

  • wolframhempel 7 hours ago

    Blatant self promotion: But if you'd like your Mermaid diagrams rendered in pretty isometric 3D, we've added Mermaid support to Arcentry lately: https://arcentry.com/blog/isometric-mermaid-diagrams-with-ar...

  • notaproton 13 hours ago

    FOUC in the big 26 is crazy work