From a00fdda6c5dbea7c335894e47fba105cf99cec06 Mon Sep 17 00:00:00 2001 From: Hermes Agent Date: Fri, 25 Sep 2026 17:19:28 -0500 Subject: [PATCH] fix(desktop): skip lone-tilde escaping on directive lines; align prose tests with the unknown-tag escape --- .../markdown-preprocess.directives.test.ts | 5 ++++- .../lib/markdown-preprocess.reasoning.test.ts | 8 ++++++- apps/desktop/src/lib/markdown-preprocess.ts | 21 ++++++++++++++++++- 3 files changed, 31 insertions(+), 3 deletions(-) diff --git a/apps/desktop/src/lib/markdown-preprocess.directives.test.ts b/apps/desktop/src/lib/markdown-preprocess.directives.test.ts index 7e8e02708a..748e4ba9de 100644 --- a/apps/desktop/src/lib/markdown-preprocess.directives.test.ts +++ b/apps/desktop/src/lib/markdown-preprocess.directives.test.ts @@ -58,8 +58,11 @@ describe('preprocessMarkdown / directive lines', () => { }) it('does not touch prose that merely contains ::', () => { + // The `::` itself is never structure, but `` is an unknown html-like + // token: escaping it to entities is the #53953 behavior (the renderer + // would otherwise swallow it), and it paints identically as literal text. const text = 'Use std::vector for *speed*.' - expect(preprocessMarkdown(text)).toBe(text) + expect(preprocessMarkdown(text)).toBe('Use std::vector<int> for *speed*.') }) }) diff --git a/apps/desktop/src/lib/markdown-preprocess.reasoning.test.ts b/apps/desktop/src/lib/markdown-preprocess.reasoning.test.ts index b179108864..ea0ebf61e7 100644 --- a/apps/desktop/src/lib/markdown-preprocess.reasoning.test.ts +++ b/apps/desktop/src/lib/markdown-preprocess.reasoning.test.ts @@ -19,6 +19,12 @@ describe('reasoning blocks in streamed markdown', () => { expect(preprocessMarkdown('Answer.\n\s]+>|https?:\/\/[^\s<>"'`*]+[^\s<>"' // literal tilde, so CJK ranges (`1~10`) and approximation prefixes (`~¥0.089`) // no longer pair up into a GFM strikethrough span. const LONE_TILDE_RE = /(?`, ``...) that are NOT // real inline elements get swallowed by the HTML-aware renderer (parse5 sees // an unclosed tag and consumes the rest of the message). Match unknown tag-like @@ -313,7 +317,22 @@ function autoLinkRawUrls(text: string): string { function escapeLoneTildes(text: string): string { return text .split(URL_LIKE_SPLIT_RE) - .map(part => (/^ { + if (/^ (DIRECTIVE_LINE_ONLY_RE.test(line) ? line : line.replace(LONE_TILDE_RE, '\\~'))) + .join('\n') + }) .join('') }