mirror of
https://github.com/open-webui/open-webui.git
synced 2026-05-07 11:28:35 -05:00
[PR #13567] [MERGED] fix(katex): Allow CJK characters adjacent to math delimiters #38868
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/13567
Author: @tth37
Created: 5/6/2025
Status: ✅ Merged
Merged: 5/8/2025
Merged by: @tjbck
Base:
dev← Head:fix_katex_chinese_delimiters📝 Commits (2)
de182ddfix(katex): Allow Chinese characters adjacent to math delimiters8e14372enh: Support more languages📊 Changes
1 file changed (+12 additions, -3 deletions)
View changed files
📝
src/lib/utils/marked/katex-extension.ts(+12 -3)📄 Description
Pull Request Checklist
Note to first-time contributors: Please open a discussion post in Discussions and describe your changes before submitting a pull request.
Before submitting, make sure you've checked the following:
devbranch.Changelog Entry
Description
The current regex patterns reject math delimiters (
$...$, etc.) when they appear directly against Chinese characters (e.g.,$A$等于$B$). This is particularly problematic because that many LLMs naturally output math expressions adjacent to Chinese text without spacing (e.g.,这里,$A$是一个矩阵,$E$是单位矩阵, more examples discussed in #13487). However, our katex validation rules require special characters/whitespace around delimiters, causing Chinese+math combinations failed to render.(Notably, in native
marked-katex-extension, this case is correctly handled.)Changed
ALLOWED_SURROUNDING_CHARSconstant\p{Script=Han}support, updated the parsing logic in lookahead checks ($x$中文) and preceding checks (中文$x$)Testings
I've also conducted some regression tests, and they all passed.
Contributor License Agreement
By submitting this pull request, I confirm that I have read and fully agree to the Contributor License Agreement (CLA), and I am providing my contributions under its terms.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.