工具 LaTeX 渲染器——LaTeX 渲染器可将 LaTeX 源码转成渲染视图:既可以是由 MathJax 排版的单个显示公式,也可以是由 faster-latex 排版的完整文档或文字片段,编辑器旁边带有实时预览,工具栏上可在编辑视图与渲染视图之间切换。源码可以手动输入、从 URL 或 GitHub Gist 加载,也可以从内置示例中选取,页面会把 LaTeX 保存在 URL 片段中,因此可以作为可读链接或压缩链接分享。
灵感来自 Paul Ford 与 Aboard Foundary 推出的新 Web 应用 Tiny Little Office,它提供了一整套 Web 内容编辑器(文字处理器、大纲工具、演示文稿构建器、电子表格、计算器、绘图工具、图表制作器、动画制作器、日历和行程规划器)。
Tiny Little Office 的标志性做法,是把所有文档数据都存放在 URL 的 #fragment 部分,因此用它创建的每份文档都成了可收藏、可分享的链接。
它还提供了 一个 llms.txt 文件,告诉智能体如何构造可渲染为文档的 URL。Claude 借助该文件生成了这个演示文稿的链接,用来讲解该 URL 格式的工作原理:
Tiny Little Office 启发我让 Claude Code(Opus 5.5 Extra)构建一个类似的、适用于 LaTeX 的工具。以下是我使用的提示词序列:
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.
由于它是在我的工具仓库里工作,我让它借鉴我现有的 SVG in Markdown 工具所用的 <iframe sandbox="..."> 机制,以防范 XSS 风险:
Safe from XSS? We could run in an iframe sandbox like we do on the SVG markdown render project
我还让它把那个工具中的 Gist/URL 加载功能也复制了过来:
We should have an option to load latex from a URL (or gist) similar to the markdown SVG tool
这是一个示例链接。该工具使用了 Pako 2.1.0、MathJax 4.1.3、faster-latex 0.3.1 和 DOMPurify 3.4.16。
