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:
Tim Jaeryang Baek 2025-06-03 21:59:12 +04:00 committed by GitHub
commit bb689b9480
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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,