From aa61831a14ee25cc88131b9fb11a03048d45b419 Mon Sep 17 00:00:00 2001 From: IAvecilla Date: Tue, 21 Apr 2026 15:32:59 -0300 Subject: [PATCH] fix(cli): keep snake_case underscores intact in strip markdown mode --- cli.py | 6 +++--- tests/cli/test_cli_markdown_rendering.py | 23 +++++++++++++++++++++++ ui-tui/src/__tests__/text.test.ts | 8 ++++++++ ui-tui/src/lib/text.ts | 4 ++-- 4 files changed, 36 insertions(+), 5 deletions(-) diff --git a/cli.py b/cli.py index aec48aef74..1ba5071ed9 100644 --- a/cli.py +++ b/cli.py @@ -1155,11 +1155,11 @@ def _strip_markdown_syntax(text: str) -> str: plain = re.sub(r"!\[([^\]]*)\]\([^\)]*\)", r"\1", plain) plain = re.sub(r"\[([^\]]+)\]\([^\)]*\)", r"\1", plain) plain = re.sub(r"\*\*\*([^*]+)\*\*\*", r"\1", plain) - plain = re.sub(r"___([^_]+)___", r"\1", plain) + plain = re.sub(r"(? { expect(estimateRows(md, 40)).toBe(2) }) + + it('keeps intraword underscores when sizing snake_case identifiers', () => { + const w = 80 + const snake = 'look at recover_with_credential_pool now' + const plain = 'look at recover with credential pool now' + + expect(estimateRows(snake, w)).toBe(estimateRows(plain, w)) + }) }) diff --git a/ui-tui/src/lib/text.ts b/ui-tui/src/lib/text.ts index fb10d7d2d4..8541ac3f68 100644 --- a/ui-tui/src/lib/text.ts +++ b/ui-tui/src/lib/text.ts @@ -25,9 +25,9 @@ const renderEstimateLine = (line: string) => { .replace(/\[(.+?)\]\((https?:\/\/[^\s)]+)\)/g, '$1') .replace(/`([^`]+)`/g, '$1') .replace(/\*\*(.+?)\*\*/g, '$1') - .replace(/__(.+?)__/g, '$1') + .replace(/(?