Skip to content

LaTeX renderer with shareable #fragment links - #354

Merged
simonw merged 3 commits into
mainfrom
latex-renderer
Oct 15, 2026
Merged

simonw merged 3 commits into
mainfrom
latex-renderer

Conversation

@simonw

@simonw simonw commented Oct 15, 2026 •

Copy link
Copy Markdown
Owner

I want a tool where you can link to it with a fragment hash #code-here and it treats that code as LaTeX and renders it really effectively. It should also support a prefix which means the latex is compressed with a custom compression dictionary optimized for latex. Use the best available latex render library from a CDN (consider WebAssembly too). If loaded without a fragment hash show an editor you can paste latex into and then toggle to a "rendered" view. That rendered view should be bookmarkable. The #fragment view should let you switch to edit source too.

Safe from XSS? We could run in an iframe sandbox like we do on the SVG markdown render project

We should have an option to load latex from a URL (or gist) similar to the markdown SVG tool

Equations render with MathJax 4 (SVG, automatic line breaking on narrow
screens); prose and full documents render with faster-latex (Rust
compiled to WebAssembly) with their maths re-typeset by MathJax.

Links are either readable (#E=mc^2) or compressed (#~1...): raw DEFLATE
with a preset dictionary tuned for LaTeX, then base64url. The editor
view lives at ?edit#..., the bookmarkable rendered view at #...

Opus 5.5 Extra: https://claude.ai/code/session_017KJrPqqWVHLqr4E7TLPnpt

Equations render with MathJax 4 (SVG, automatic line breaking on narrow
screens); prose and full documents render with faster-latex (Rust
compiled to WebAssembly) with their maths re-typeset by MathJax.

Links are either readable (#E=mc^2) or compressed (#~1...): raw DEFLATE
with a preset dictionary tuned for LaTeX, then base64url. The editor
view lives at ?edit#..., the bookmarkable rendered view at #...

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017KJrPqqWVHLqr4E7TLPnpt
- DOMPurify now returns a DOM fragment, so sanitized markup is never
  re-parsed (the route mutation-XSS bypasses take)
- Regression tests fire XSS payloads through both renderers and assert
  nothing runs; removing MathJax's safe extension makes them fail
- New Prose and TikZ examples; loading an example over an edited draft
  asks first, and Back restores the draft
- TikZ labels no longer wrap at MathJax's inline line-break points

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017KJrPqqWVHLqr4E7TLPnpt
All rendering (MathJax, faster-latex, DOMPurify) now runs in an iframe
with sandbox="allow-scripts", like the HTML blocks in the Markdown SVG
renderer. Its opaque origin cannot reach this page, cookies or the API
keys other tools keep in localStorage. The frame's srcdoc carries a CSP
allowing only its inline scripts (hashed at runtime, so they cannot go
stale) and the pinned CDN paths; remote images are blocked so links
cannot act as tracking pixels. The parent treats every message from the
frame as untrusted, opens only http(s) links, and strips exported SVG
down to inert markup.

New: load LaTeX from a raw URL, a GitHub Gist or a github.com file page,
via a form in the editor or ?url= links, which stay short and follow
changes to the file. Editing turns it into a local #fragment copy.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017KJrPqqWVHLqr4E7TLPnpt
@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying tools with  Cloudflare Pages  Cloudflare Pages

Latest commit: b65f44d
Status: ✅  Deploy successful!
Preview URL: https://6eb0e710.tools-b1q.pages.dev
Branch Preview URL: https://latex-renderer.tools-b1q.pages.dev

View logs

@simonw
simonw merged commit 955cd79 into main Oct 15, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants