mirror of
https://github.com/open-webui/open-webui
synced 2025-06-26 18:26:48 +00:00
Merge pull request #14630 from Yu-QX/main
fix: Rendering problem with Chinese quotation mark in **bold** & *italic* (after Chinese parentheses issue).
This commit is contained in:
commit
bb689b9480
@ -106,7 +106,7 @@ function processChineseContent(content: string): string {
|
||||
if (/[\u4e00-\u9fa5]/.test(line)) {
|
||||
// Problems caused by Chinese parentheses
|
||||
/* Discription:
|
||||
* When `*` has Chinese parentheses on the inside, markdown parser ignore bold or italic style.
|
||||
* When `*` has Chinese delimiters on the inside, markdown parser ignore bold or italic style.
|
||||
* - e.g. `**中文名(English)**中文内容` will be parsed directly,
|
||||
* instead of `<strong>中文名(English)</strong>中文内容`.
|
||||
* Solution:
|
||||
@ -118,10 +118,17 @@ function processChineseContent(content: string): string {
|
||||
* Change the behavior in future if needed.
|
||||
*/
|
||||
if (line.includes('*')) {
|
||||
// Handle **bold** with Chinese parentheses
|
||||
line = processChineseParentheses(line, '**', '(', ')');
|
||||
// Handle *italic* with Chinese parentheses
|
||||
line = processChineseParentheses(line, '*', '(', ')');
|
||||
// Handle **bold** and *italic*
|
||||
// 1. With Chinese parentheses
|
||||
if (/(|)/.test(line)) {
|
||||
line = processChineseDelimiters(line, '**', '(', ')');
|
||||
line = processChineseDelimiters(line, '*', '(', ')');
|
||||
}
|
||||
// 2. With Chinese quotations
|
||||
if (/“|”/.test(line)) {
|
||||
line = processChineseDelimiters(line, '**', '“', '”');
|
||||
line = processChineseDelimiters(line, '*', '“', '”');
|
||||
}
|
||||
}
|
||||
}
|
||||
return line;
|
||||
@ -132,7 +139,7 @@ function processChineseContent(content: string): string {
|
||||
}
|
||||
|
||||
// Helper function for `processChineseContent`
|
||||
function processChineseParentheses(
|
||||
function processChineseDelimiters(
|
||||
line: string,
|
||||
symbol: string,
|
||||
leftSymbol: string,
|
||||
|
Loading…
Reference in New Issue
Block a user