From 5d1f350784f8a232df36f9527741c6c2ab962035 Mon Sep 17 00:00:00 2001 From: felix-windsor <172729123+felix-windsor@users.noreply.github.com> Date: Mon, 18 May 2026 20:08:31 -0700 Subject: [PATCH] fix(cli): preserve cron asterisks in strip mode --- cli.py | 13 +++++++++++-- tests/cli/test_cli_markdown_rendering.py | 12 ++++++++++++ 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/cli.py b/cli.py index 036e233d3c7..af3504af242 100644 --- a/cli.py +++ b/cli.py @@ -1569,7 +1569,14 @@ def _rich_text_from_ansi(text: str) -> _RichText: def _strip_markdown_syntax(text: str) -> str: """Best-effort markdown marker removal for plain-text display.""" plain = _rich_text_from_ansi(text or "").plain - plain = re.sub(r"^\s{0,3}(?:[-*_]\s*){3,}$", "", plain, flags=re.MULTILINE) + # Avoid stripping cron-style expressions like "* * * * *" as if they were + # Markdown horizontal rules. CommonMark treats three or more "*" as an HR, + # but in Hermes output it's common to display cron schedules verbatim. + # + # Keep the behavior for "-" / "_" HR markers, and only strip "*" HR lines + # when there are exactly 3 asterisks (with optional whitespace). + plain = re.sub(r"^\s{0,3}(?:[-_]\s*){3,}$", "", plain, flags=re.MULTILINE) + plain = re.sub(r"^\s{0,3}(?:\*\s*){3}\s*$", "", plain, flags=re.MULTILINE) plain = re.sub(r"^\s{0,3}#{1,6}\s+", "", plain, flags=re.MULTILINE) # Preserve blockquotes, lists, and checkboxes because they carry structure. plain = re.sub(r"(```+|~~~+)", "", plain) @@ -1580,7 +1587,9 @@ def _strip_markdown_syntax(text: str) -> str: plain = re.sub(r"(?