MCPcopy Create free account
hub / github.com/diillson/chatcli / stripANSIForTest

Function stripANSIForTest

cli/cli_rendering_test.go:74–91  ·  view source on GitHub ↗

stripANSIForTest removes CSI sequences so visible-content assertions run on plain text.

(s string)

Source from the content-addressed store, hash-verified

72// stripANSIForTest removes CSI sequences so visible-content assertions run on
73// plain text.
74func stripANSIForTest(s string) string {
75 var b strings.Builder
76 esc := false
77 for _, c := range s {
78 if c == '\033' {
79 esc = true
80 continue
81 }
82 if esc {
83 if (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') {
84 esc = false
85 }
86 continue
87 }
88 b.WriteRune(c)
89 }
90 return b.String()
91}
92
93// TestRenderMarkdown_ResolvesReferenceLinksAcrossCodeBlocks is the regression
94// guard for the whole-document render: a reference link whose definition sits

Calls 1

StringMethod · 0.45

Tested by

no test coverage detected