Repository navigation
Replies: 1 comment 1 reply
|
+1. The mobile point at the end is the part I'd most like to see. On the iOS app, Mermaid fences in chat don't render today, so plans and architecture sketches from agents don't work on my phone. I checked that Pele's One thing a mobile adapter has to handle: colors come through One renderer across web, desktop and mobile also means a fence looks the same everywhere. #14721 targets the same mobile gap with beautiful-mermaid and a limited syntax subset; Pele covers every Mermaid 12.1 diagram type. Checked with claude-opus-5-5 in Claude Code. |
Uh oh!
There was an error while loading. Please reload this page.

## Render Mermaid diagrams with Pele instead of mermaidPele (obsidianmd/pele, MIT) is a new Mermaid renderer from the Obsidian team. It's synchronous, has no runtime dependencies and supports every diagram type built into Mermaid 12.1. It writes SVG strings without touching the DOM, and its colors come from CSS variables.
I swapped it into
apps/web/src/components/chat/MermaidDiagram.tsxon a fork: gsimone/t3code@feat/pele-mermaid (diff)Why
--pele-*CSS variables, which the branch maps to the app's theme tokens, so diagrams recolor in place, including in custom themes.mermaid.initializeconfig, no serialized render queue, no theme in the cache key. The SVGs are 4 to 7 times smaller, so the existing DOMPurify pass has less to do.What the branch changes
MermaidDiagramloadspele/lazy, which fetches one chunk per diagram type, and renders with links and images turned off. The existing DOMPurify sanitizer still runs, now without theforeignObjectand HTML allowances mermaid needed.index.cssmaps--pele-*to--background,--foreground,--muted-foreground,--accent,--primaryand so on.mermaidis removed fromapps/web.MermaidDiagram.browser.test.tsxchecks that labels survive sanitization, links are dropped, syntax errors don't offer a retry, and the expanded image keeps the theme colors.Screenshots
Same Markdown file (diagrams.md), opened in the file preview.
Benchmark
Headless Chromium 148 on an M1 Pro. Each renderer runs the same code path as its version of
MermaidDiagram: per-renderinitializeandmermaid.renderon main,renderAsyncon the branch. Times are medians in ms.All eight diagram types rendered with both renderers. Script and raw results: pele-mermaid-evidence/bench.
Caveats and open questions
styleorclassDefkeep those fixed colors.flowchart LRdiagrams in narrow panels shrink with both renderers. Pele can re-lay a diagram out for its container width (maxWidth/mount()), which could be a follow-up.minimumReleaseAgeExcludeentry. Waiting out the release-age window instead would also work.Would you be open to this swap? If so, I can open a PR from the branch.
All reactions