[PR #23717] [CLOSED] Feat katex2mathjax 18507 #42961

Closed
opened 2026-04-25 14:42:54 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/open-webui/open-webui/pull/23717
Author: @jorgeventura
Created: 4/14/2026
Status: Closed

Base: mainHead: feat-katex2mathjax-18507


📝 Commits (6)

  • 65c67dd Save to avoid lose something at this point
  • fa88078 Beginning to work, matrices as well.
  • f4a7782 Matrices are working
  • cf270cf Needs remove $ in excess
  • 9e78732 The $ excess fixed.
  • 30949fe feat(math): complete KaTeX to MathJax migration and chemistry support

📊 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

refactor(math): migrate math rendering engine from KaTeX to MathJax. The feature request #18508 was the motivation .

Summary

This PR completes the migration of the math rendering engine from KaTeX to MathJax. This is a foundational change to how mathematical notation is processed and displayed within the application. The support for chemistry was also included.

Motivation

The migration was driven by the need for:

  • Enhanced LaTeX Support: Improved compatibility with complex LaTeX environments and packages that were previously unsupported by KaTeX.
  • Consistency: Aligning our math rendering capabilities with broader web standards and providing more robust handling of edge-case delimiters.
  • [Add any other reason here, e. configuration/performance/etc.]

Key Changes

  • Tokenizer Refactoring: Updated src/lib/utils/marked/math-extension.ts and related utilities to handle MathJax-specific delimiters and delimiters (e.g., \ce{}, \pu{}, \begin{equation}).
  • Dependency Update: Removed KaTeX dependencies and integrated MathJax library.
  • Renderer Update: Replaced KaTeX-specific HTML output generation with MathJax-compatible rendering logic.
  • Regex/Pattern Updates: Adjusted regular expressions in the marked extensions to accurately identify math blocks and inline math under the new engine's requirements.

Testing Performed

  • Verified rendering of standard inline math ($ ... $).
  • Verified rendering of block math ($$ ... $$).
  • Tested complex environments (e.g., \begin{equation}, \ce{}).
  • Checked for regression in existing markdown content.

Impact

  • Breaking Changes: None. Existing markdown syntax remains compatible.
  • Dependencies: New dependency on MathJax added; KaTeX removed.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/open-webui/open-webui/pull/23717 **Author:** [@jorgeventura](https://github.com/jorgeventura) **Created:** 4/14/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `feat-katex2mathjax-18507` --- ### 📝 Commits (6) - [`65c67dd`](https://github.com/open-webui/open-webui/commit/65c67ddc0d379baa5ee5340a3cdaa70439df2e5f) Save to avoid lose something at this point - [`fa88078`](https://github.com/open-webui/open-webui/commit/fa880784ec9e91ee20ac06d500327d1c51167c21) Beginning to work, matrices as well. - [`f4a7782`](https://github.com/open-webui/open-webui/commit/f4a7782fe4c4bb3c501b26dbf9182d0304b6a97a) Matrices are working - [`cf270cf`](https://github.com/open-webui/open-webui/commit/cf270cf904723c52537bb677d2091bb11fe034ad) Needs remove $ in excess - [`9e78732`](https://github.com/open-webui/open-webui/commit/9e7873218fdc048e311fa2d9326f4d5575657dfd) The $ excess fixed. - [`30949fe`](https://github.com/open-webui/open-webui/commit/30949fea7f2677b3fc4b4579ab1be1ac9aec0070) feat(math): complete KaTeX to MathJax migration and chemistry support ### 📊 Changes **12 files changed** (+224 additions, -111 deletions) <details> <summary>View changed files</summary> 📝 `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) </details> ### 📄 Description refactor(math): migrate math rendering engine from KaTeX to MathJax. The feature request #18508 was the motivation . ### Summary This PR completes the migration of the math rendering engine from KaTeX to MathJax. This is a foundational change to how mathematical notation is processed and displayed within the application. The support for chemistry was also included. ### Motivation The migration was driven by the need for: - **Enhanced LaTeX Support:** Improved compatibility with complex LaTeX environments and packages that were previously unsupported by KaTeX. - **Consistency:** Aligning our math rendering capabilities with broader web standards and providing more robust handling of edge-case delimiters. - [Add any other reason here, e. configuration/performance/etc.] ### Key Changes - **Tokenizer Refactoring:** Updated `src/lib/utils/marked/math-extension.ts` and related utilities to handle MathJax-specific delimiters and delimiters (e.g., `\ce{}`, `\pu{}`, `\begin{equation}`). - **Dependency Update:** Removed KaTeX dependencies and integrated MathJax library. - **Renderer Update:** Replaced KaTeX-specific HTML output generation with MathJax-compatible rendering logic. - **Regex/Pattern Updates:** Adjusted regular expressions in the marked extensions to accurately identify math blocks and inline math under the new engine's requirements. ### Testing Performed - [ ] Verified rendering of standard inline math (`$ ... $`). - [ ] Verified rendering of block math (`$$ ... $$`). - [ ] Tested complex environments (e.g., `\begin{equation}`, `\ce{}`). - [ ] Checked for regression in existing markdown content. ### Impact - **Breaking Changes:** None. Existing markdown syntax remains compatible. - **Dependencies:** New dependency on MathJax added; KaTeX removed. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-04-25 14:42:54 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/open-webui#42961