mirror of
https://github.com/open-webui/open-webui.git
synced 2026-05-06 10:58:17 -05:00
[PR #23791] [CLOSED] feat: replace katex engine to mathjax #27368
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/23791
Author: @jorgeventura
Created: 4/16/2026
Status: ❌ Closed
Base:
dev← Head:feat-mathjax-dev📝 Commits (6)
5fc8696Feat: Integrate MathJax support for math renderingb7366feRefactor math delimiter regex for block contentd6edf06Matrices are workingbb95afcNeeds remove $ in excess40f38abThe $ excess fixed.369c55cfeat(math): complete KaTeX to MathJax migration and chemistry support📊 Changes
12 files changed (+247 additions, -126 deletions)
View changed files
📝
package-lock.json(+16 -1)📝
package.json(+1 -1)📝
src/app.css(+8 -8)📝
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(+24 -9)📝
src/lib/utils/marked/math-extension.ts(+68 -64)📝
vite.config.ts(+3 -0)📄 Description
Title:
feat: migrate from KaTeX to MathJax for enhanced Mathematics and Chemistry renderingImportant Note
This migration from KaTeX to MathJax was initiated due to bugs found in the main branch. While I have now rebased this against dev (where some KaTeX fixes are already present), I am providing this patch as a complete MathJax replacement as an option to the core team.
Pull Request Checklist
devbranch.featprefix applied.Description
$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.fix:
KaTeX. Migrating toMathJaxeliminates these problems, many of which stem from KaTeX's inherent design limitations.Breaking Change
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.