Render LaTeX math in Markdown previews - #57339
Conversation
d215f84 to
0676a0c
Compare
In case there is any mixup, the other works you referenced involve the KenyC fork (much more modular, last commit 3 months ago). Indeed the original rex repo is not very active. On the flip side I would be a little wary in the year 2026 of the reliability of a young project with a flashy website. |
移植上游 PR zed-industries#57339:启用 pulldown-cmark 的 ENABLE_MATH, 新增 katex.rs,公式经 RaTeX 输出 SVG 后复用 GPUI 栅格化管线, 与 mermaid 同构(后台异步渲染、缓存、主题联动、失败回退源码)。 - render_mermaid_diagrams 更名为 render_embedded_diagrams - 保留 fork 的标题 mt_6 与 h1-h3 底边框样式 - 适配 fork 的 DivStackEntry 与 parse_markdown_with_options 签名 - 新增依赖 ratex-{layout,parser,svg,types} 0.1
|
Is this feature still considered? LaTeX-style Markdown formula preview with RaTeX is a solid approach and would greatly improve documentation and note taking. |
|
I don’t know why this isn’t on their priority list. Without equation rendering, it doesn’t feel feature complete to me (as well as a lot of ppl) as an editor. |
This comment was marked as spam.
This comment was marked as spam.
|
Wouldn't it be better to start afresh? There have been some changes in the markdown API since v11.x and it may be necessary to rethink the integration. RaTeX is super nice and rusted, so definitely a win on top of VSCode js approach. |
This comment was marked as spam.
This comment was marked as spam.
@RamonOpazo @Cyfine @lamthanhhiep85 Please check this comment; this PR has implemented a highly usable Markdown preview and agent panel Markdown formulas. |
|
There are three competing RaTeX implementation pull requests:
But keep in mind that LaTeX support was already closed in 2024 as "not planned": And confirmed again in 2026 as "out of scope and not on our roadmap" because Zed is a code editor. It's not a LaTeX math formula renderer: But it was reopened (without comment), so maybe there's a chance. If so, someone will have to take the time to figure out which of all the pull requests is the cleanest solution. And more importantly: Explain why Zed needs to render math formulas. |


Closes #40813
Summary
pulldown-cmarkmath parsing and preserveInlineMath/DisplayMathevents instead of dropping them.ratex, converting formulas to SVG images rendered by GPUI.$...$and display$$...$$formulas in Markdown rendering paths that already support embedded diagrams.Screenshots
Notes
This follows up on the open Markdown preview request in #40813 and the duplicate
$math rendering report in #57001.I also checked the related ReX-based attempts in #53150 and #54668. Those PRs explored LaTeX math rendering through ReX-based rendering paths, but ReX has not been very active recently.
This PR uses the RaTeX instead. RaTeX is a KaTeX-compatible math renderer written in Rust: its parser architecture, symbol tables, font metrics, and layout semantics are based on KaTeX, while still producing native Rust display output. In this implementation, Zed parses and lays out formulas with
ratex, exports them throughratex-svg, and renders the SVG through GPUI's existing SVG renderer.Testing
Release Notes: