fix(tui): use single space after ordered-list marker (#1043)

This commit is contained in:
OpenPay
2026-08-20 13:40:12 -07:00
committed by GitHub
parent deb2057e20
commit fe758af4fc
2 changed files with 14 additions and 1 deletions
@@ -100,7 +100,7 @@ func applyMarkdownStyles(text string) string {
case strings.HasPrefix(line, "- "), strings.HasPrefix(line, "* "):
out.WriteString(Col(Green).Render("• ") + inlineFormat(line[2:]))
case len(line) > 2 && line[0] >= '0' && line[0] <= '9' && (line[1:3] == ". " || line[1:3] == ") "):
out.WriteString(Col(Green).Render(string(line[0])+". ") + inlineFormat(line[2:]))
out.WriteString(Col(Green).Render(line[:2]+" ") + inlineFormat(line[3:]))
case line == "---" || line == "***" || line == "___":
out.WriteString(Col(Green).Render(strings.Repeat("─", 40)))
default:
@@ -72,6 +72,19 @@ func TestNonTablePipeLinesAreLeftAlone(t *testing.T) {
}
}
func TestMarkdownOrderedListsUseSingleSpaceAfterMarker(t *testing.T) {
out := renderAssistantMarkdown("1. hello\n2) world")
plain := ansi.Strip(out)
for _, want := range []string{"1. hello", "2) world"} {
if !strings.Contains(plain, want) {
t.Fatalf("ordered list item %q missing: %q", want, plain)
}
}
if strings.Contains(plain, "1. hello") || strings.Contains(plain, "2) world") {
t.Fatalf("double space after the list marker: %q", plain)
}
}
func TestInlineFormatKeepsNonEmphasisMarkers(t *testing.T) {
literal := []string{
"ls *.py *.go",