chadtmiller.com/knotless
git that lives in your Atmosphere account
1
10
The iOS app draws Mermaid diagrams in Markdown, as the pages do
Merged Approved
This draws mermaid fences in the iOS app's Markdown by running Pele in a script-only JSContext, then showing the SVG in a WKWebView with JavaScript off, a non-persistent store, and every navigation but about:blank cancelled. I found nothing that must change.
- Parsing and caching: The fence and language parsing in
Markdown.swiftis correct. A block that fails to render falls back to its source, and the render cache is bounded. - Security: The security story holds up, and
docs/design/security.mdis updated to match. - Vendored file: I did not read the vendored
ios/Knotless/Vendor/pele.jsline by line. It is minified third-party code, and its/*! Pele 1.8.0header is whatcheck-pele.shparses. - Checks: No runs are listed for this pull yet. The build and the
ioscheck are untested here, and Xcode can't build on CI anyway. - Pele call can hang:
knotlessDrawhas no time limit. A pathological diagram that makes Pele loop would stall the wholeDiagramsactor, and with it every diagram in the app. I think that's rare, so I'm not holding the pull for it. check-pele.shcompares versions, not content: A hand-editedpele.jswith the right header passes. Comparing a hash ofweb/node_modules/pele/dist/pele.global.jswould catch that, but it needsnpm ciin the check.
All checks have passed
8 passed, 2 skipped
Merged as c736257
What changes
A
mermaidblock in Markdown on the iOS app (pull and issue bodies, comments, READMEs, release notes, commit messages) is drawn as a diagram, as the pages draw it, rather than shown as code. One Pele can't draw keeps showing its source.How it's drawn. Pele's
render()needs no DOM, so it runs in aJSContextof its own, with no page or network, measuring words with the system font through CoreText. The SVG it makes is shown in aWKWebViewwith JavaScript off, no website data, and every navigation but its own page turned away. Colours are the app's own (grouped card background, labels, accent, danger) for light and dark. A diagram wider than the screen scrolls sideways, as a code block does. Pele'smaxWidthturns a wide flowchart vertical first.Pele's version.
ios/Knotless/Vendor/pele.jsis thepele.global.jsof the versionweb/package-lock.jsonpins (1.8.0).just ios-pelecopies it after a bump inweb/, and theioscheck (now also run on a change toweb/package-lock.json) fails while the two differ.Why
The pages draw these diagrams with Pele. The app showed their source. Running Pele in JavaScriptCore keeps untrusted diagram text out of any web view that runs script, and drawing the SVG in WebKit keeps Pele's CSS-variable theming, which native SVG libraries don't read. Rendering on the server was the other way. It would need a JS engine in serve, and the app would still need to draw SVG.
How it was checked
Built for the simulator.
just ios-look issue-openwith the issue's body set to a flowchart, a sequence diagram and a block that doesn't parse, light and dark (pictures attached): both draw, the text fits its boxes, and the broken one shows as code.Shortcomings
🤖 Generated with Claude Code