mirror of
https://github.com/open-webui/open-webui.git
synced 2026-05-06 10:58:17 -05:00
[PR #23744] [CLOSED] Feat: Migrate from KaTeX to MathJax for enhanced Mathematics and Chemistry rendering #42980
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/open-webui/open-webui/pull/23744
Author: @jorgeventura
Created: 4/15/2026
Status: ❌ Closed
Base:
dev← Head:feat-katex2mathjax-18507📝 Commits (10+)
fe6783cMerge pull request #19030 from open-webui/devfc05e0aMerge pull request #19405 from open-webui/deve3faec6Merge pull request #19416 from open-webui/dev9899293Merge pull request #19448 from open-webui/dev140605eMerge pull request #19462 from open-webui/dev6f1486fMerge pull request #19466 from open-webui/devd95f533Merge pull request #19729 from open-webui/deva7271530.6.43 (#20093)6adde20Merge pull request #20394 from open-webui/devf9b0534Merge pull request #20522 from open-webui/dev📊 Changes
12 files changed (+224 additions, -111 deletions)
View changed files
📝
package-lock.json(+16 -1)📝
package.json(+1 -1)📝
src/app.css(+7 -11)📝
src/app.html(+30 -0)📝
src/lib/components/chat/Messages/Markdown.svelte(+2 -2)➖
src/lib/components/chat/Messages/Markdown/KatexRenderer.svelte(+0 -33)📝
src/lib/components/chat/Messages/Markdown/MarkdownInlineTokens.svelte(+3 -3)📝
src/lib/components/chat/Messages/Markdown/MarkdownTokens.svelte(+5 -5)➕
src/lib/components/chat/Messages/Markdown/MathRenderer.svelte(+87 -0)📝
src/lib/utils/index.ts(+2 -2)📝
src/lib/utils/marked/math-extension.ts(+68 -53)📝
vite.config.ts(+3 -0)📄 Description
Title:
feat: Migrate from KaTeX to MathJax for enhanced Mathematics and Chemistry renderingDescription
$symbols).Added
mhchemextension, allowing users to render chemical equations via\ce{}.\pu{}and\ce{}delimiters was preserved to the markdown tokenizer to support scientific notation and chemical formulas natively.Changed
src/app.html: Added globalMathJaxconfiguration, includingamsandmhchempackages.src/lib/utils/marked/math-extension.ts: Refactored the math tokenizer to prioritize block-mode equations over inline, ensuring correct handling of multi-line environments like matrices.src/lib/components/chat/Messages/Markdown/MathRenderer.svelte: Replaced KaTeX-specific rendering logic with MathJax’s asynchronoustypesetPromiseto resolve race conditions and rendering artifacts.package.json: Addedmathjaxdependency andkatexwas removed.Fixed
KaTeX. Migrating toMathJaxeliminates these problems, many of which stem from KaTeX's inherent design limitations.Breaking Changes
KaTeXdependency. We have reviewed all custom CSS and logic relying on KaTeX-specific class names to ensure compatibility. This transition significantly improves rendering stability for complex scientific content.Additional Information
pmatrix,bmatrix).\ce{}.Screenshots or Videos
Contributor License Agreement
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.