fix(line): preserve underscores inside words in stripMarkdown (#47465)

Fixes #46185.

Verified:
- pnpm install --frozen-lockfile
- pnpm build
- pnpm test -- extensions/line/src/markdown-to-line.test.ts src/tts/prepare-text.test.ts

Note: `pnpm check` currently fails on unchanged `extensions/microsoft/speech-provider.test.ts` lines 108 and 139 on the rebased base, outside this PR diff.
This commit is contained in:
Jackjin
2026-03-29 10:31:09 +08:00
committed by GitHub
parent e61ffa68f1
commit a0407c7254
4 changed files with 37 additions and 1 deletions

View File

@@ -9,7 +9,7 @@ export function stripMarkdown(text: string): string {
result = result.replace(/__(.+?)__/g, "$1");
result = result.replace(/(?<!\*)\*(?!\*)(.+?)(?<!\*)\*(?!\*)/g, "$1");
result = result.replace(/(?<!_)_(?!_)(.+?)(?<!_)_(?!_)/g, "$1");
result = result.replace(/(?<![\p{L}\p{N}])_(?!_)(.+?)(?<!_)_(?![\p{L}\p{N}])/gu, "$1");
result = result.replace(/~~(.+?)~~/g, "$1");
result = result.replace(/^#{1,6}\s+(.+)$/gm, "$1");