# 在Cloudflare Workers边缘编译LaTeX的坑

Original title: Shipping a LaTeX Compiler Behind an Edge App

> Hacker News story 50149609 · language: zh · submitted 2026-10-19
> Web version: https://zeli.app/zh/story/50149609
> About this feed: https://zeli.app/llms.txt · Agent guide: https://zeli.app/skill.md

▲ 13 · by [brgv](<https://news.ycombinator.com/user?id=brgv>) · 💬 7
[original](<https://bhargav.dev/writing/shipping-a-latex-compiler-behind-an-edge-app>) · [HN discussion](<https://news.ycombinator.com/item?id=50149609>)

## Summary

我想在Cloudflare Workers上构建一个简历生成器，却遇到了边缘环境无法运行LaTeX编译器的难题。Workers本质是V8 isolate，无法启动原生二进制程序，而LaTeX需要完整的操作系统支持。最终方案是将编译任务移至容器，使用Tectonic引擎按需获取依赖并关闭shell escape以防代码注入。过程中我踩了环境泄露和临时文件竞态条件的坑，深刻体会到边缘计算与容器化服务的架构差异。

## Key quote

> 一个isolate运行JavaScript，一个容器运行计算机，LaTeX需要的是计算机。

## HN discussion (7 comments)

### [dunham](<https://news.ycombinator.com/item?id=50174871>)

> 你看过这个吗：https://github.com/kisonecat/web2js
>
> 它是通过将 Pascal 编译为 wasm 来实现的 TeX 在 wasm 上的运行，这看起来是个很新颖的思路。（TeX 本身是用 Pascal 写的，通常构建前会先转成 C。）
>
> TeX 本身是一个 500kb 的 wasm 文件（压缩后为 90k），但如果预加载了 LaTeX 等组件，生成的图片会大得多。
>
> （作者在这个仓库中用它来在浏览器中运行 tikz：https://github.com/kisonecat/tikzjax）

### [WillAdams](<https://news.ycombinator.com/item?id=50175043>)

> 曾经，我亲手用 Plain TeX 编写过我的简历，但在多次申请 TeX 排版相关职位时，HR 却要求我提供 Word .doc 版本。
>
> 几年后，当 PDF 更为普及时，我在一场面试中得知，我提交的 .pdf 文件被转换成了纯文本，然后上传到了简历数据库中。由于我使用了旧式图形、小型大写字母和连字，编码问题导致提取出的文本几乎无法阅读。
>
> 或许确保 PDF 带有适当的标签会很有帮助，这样任何自动化处理都能提取出有用的文本？

### [wolfi1](<https://news.ycombinator.com/item?id=50149729>)

> 我自己也在考虑做一个 (La)TeX，不过更倾向于 eXTeX[0] 这种思路，因为它是用 Java 写的。[0] https://github.com/tex-other/extex/tree/master

---

## Cite

- Page: https://zeli.app/zh/story/50149609
- Date: 2026-10-19
- Source: bhargav.dev (https://bhargav.dev/writing/shipping-a-latex-compiler-behind-an-edge-app)
- Hacker News: https://news.ycombinator.com/item?id=50149609

## Other languages

- en: https://zeli.app/story/50149609 · markdown: https://zeli.app/story/50149609.md
- ja: https://zeli.app/ja/story/50149609 · markdown: https://zeli.app/ja/story/50149609.md
- ko: https://zeli.app/ko/story/50149609 · markdown: https://zeli.app/ko/story/50149609.md
- de: https://zeli.app/de/story/50149609 · markdown: https://zeli.app/de/story/50149609.md
- es: https://zeli.app/es/story/50149609 · markdown: https://zeli.app/es/story/50149609.md
- ru: https://zeli.app/ru/story/50149609 · markdown: https://zeli.app/ru/story/50149609.md
