From 9585e4a570ae76855fb641aed4681f5717c8a949 Mon Sep 17 00:00:00 2001 From: Gubarz <1037896+Gubarz@users.noreply.github.com> Date: Sun, 31 May 2026 13:53:32 -0600 Subject: [PATCH] fix(parser): correct misleading ANSI warning message --- pkg/parser/parser.go | 2 +- pkg/parser/parser_ansi_test.go | 25 +++++++++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 pkg/parser/parser_ansi_test.go diff --git a/pkg/parser/parser.go b/pkg/parser/parser.go index 45cddfb..df2259a 100644 --- a/pkg/parser/parser.go +++ b/pkg/parser/parser.go @@ -512,7 +512,7 @@ func (p *Parser) createCheat(path string, s *parseState, block codeBlock, cheatB p.index.Errors = append(p.index.Errors, ParseError{ File: path, Line: cheatLine, - Message: "cheat contains raw ANSI escape sequences which will be sanitized", + Message: "cheat contains raw ANSI escape sequences which may cause parsing errors. Please remove them manually.", }) } diff --git a/pkg/parser/parser_ansi_test.go b/pkg/parser/parser_ansi_test.go new file mode 100644 index 0000000..324abac --- /dev/null +++ b/pkg/parser/parser_ansi_test.go @@ -0,0 +1,25 @@ +package parser + +import ( + "strings" + "testing" +) + +func TestANSIWarningMessage(t *testing.T) { + p := NewParser() + content := []byte("# \x1b[31mCheat\x1b[0m\n```bash\necho 1\n```\n") + + p.parseLines("test.md", content) + + // Create cheats so createCheat runs + _ = p.index.Cheats + + if len(p.index.Errors) != 1 { + t.Fatalf("expected 1 error, got %d", len(p.index.Errors)) + } + + errMessage := p.index.Errors[0].Message + if !strings.Contains(errMessage, "Please remove them manually") { + t.Errorf("expected warning to mention manual removal, got %q", errMessage) + } +}