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)) { if (/[\u4e00-\u9fa5]/.test(line)) {
// Problems caused by Chinese parentheses // Problems caused by Chinese parentheses
/* Discription: /* 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, * - e.g. `**中文名English**中文内容` will be parsed directly,
* instead of `<strong>中文名English</strong>中文内容`. * instead of `<strong>中文名English</strong>中文内容`.
* Solution: * Solution:
@ -118,10 +118,17 @@ function processChineseContent(content: string): string {
* Change the behavior in future if needed. * Change the behavior in future if needed.
*/ */
if (line.includes('*')) { if (line.includes('*')) {
// Handle **bold** with Chinese parentheses // Handle **bold** and *italic*
line = processChineseParentheses(line, '**', '', ''); // 1. With Chinese parentheses
// Handle *italic* with Chinese parentheses if (/|/.test(line)) {
line = processChineseParentheses(line, '*', '', ''); line = processChineseDelimiters(line, '**', '', '');
line = processChineseDelimiters(line, '*', '', '');
}
// 2. With Chinese quotations
if (/“|”/.test(line)) {
line = processChineseDelimiters(line, '**', '“', '”');
line = processChineseDelimiters(line, '*', '“', '”');
}
} }
} }
return line; return line;
@ -132,7 +139,7 @@ function processChineseContent(content: string): string {
} }
// Helper function for `processChineseContent` // Helper function for `processChineseContent`
function processChineseParentheses( function processChineseDelimiters(
line: string, line: string,
symbol: string, symbol: string,
leftSymbol: string, leftSymbol: string,