fix(tui): remove double space after numbered-list marker

The ordered-list branch in _apply_markdown_styles emitted its own
"N. " prefix and then re-rendered the remainder from line[2:], which
still includes the marker's trailing space (a numbered marker like
"1. " is 3 chars). The result was a doubled space, e.g. "1.  Hello".
Slice from line[3:] to skip the whole marker, matching the 2-char
bullet branch that already uses line[2:]. Add regression tests.

Closes #684
This commit is contained in:
Sean Kim 2026-07-04 15:08:42 -07:00
parent 302efedca6
commit 1a2444c50a
2 changed files with 24 additions and 1 deletions

View file

@ -104,7 +104,7 @@ def _apply_markdown_styles(text: str) -> Text: # noqa: PLR0912
result.append_text(_process_inline_formatting(line[2:]))
elif len(line) > 2 and line[0].isdigit() and line[1:3] in (". ", ") "):
result.append(line[0] + ". ", style="#22c55e")
result.append_text(_process_inline_formatting(line[2:]))
result.append_text(_process_inline_formatting(line[3:]))
elif line.strip() in ("---", "***", "___"):
result.append("─" * 40, style="#22c55e")
else:

View file

@ -0,0 +1,23 @@
"""Tests for markdown styling in the agent-message TUI renderer."""
from __future__ import annotations
from strix.interface.tui.renderers.agent_message_renderer import _apply_markdown_styles
def test_numbered_list_has_single_space_after_marker() -> None:
result = _apply_markdown_styles("1. Hello").plain
assert result == "1. Hello"
assert "1. Hello" not in result
def test_numbered_list_paren_marker_normalized_single_space() -> None:
result = _apply_markdown_styles("2) World").plain
assert result == "2. World"
assert "2. World" not in result
def test_bullet_list_marker_unaffected() -> None:
assert _apply_markdown_styles("- Item").plain == "• Item"