From 3b1b9248be7aabebb423673071a10730cd8a59b6 Mon Sep 17 00:00:00 2001 From: Ayman Bagabas Date: Tue, 4 Feb 2025 13:27:29 -0500 Subject: [PATCH] fix(table): crlf on windows --- table/table_test.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/table/table_test.go b/table/table_test.go index 8c6da37..cfe8780 100644 --- a/table/table_test.go +++ b/table/table_test.go @@ -1,6 +1,7 @@ package table import ( + "strings" "testing" "github.com/charmbracelet/lipgloss/v2" @@ -124,7 +125,7 @@ func TestTableAlignment(t *testing.T) { {"Hobnobs", "UK", "Yes"}, }), ) - got := ansi.Strip(biscuits.View()) + got := ansiStrip(biscuits.View()) golden.RequireEqual(t, []byte(got)) }) t.Run("With border", func(t *testing.T) { @@ -153,7 +154,13 @@ func TestTableAlignment(t *testing.T) { }), WithStyles(s), ) - got := ansi.Strip(baseStyle.Render(biscuits.View())) + got := ansiStrip(baseStyle.Render(biscuits.View())) golden.RequireEqual(t, []byte(got)) }) } + +func ansiStrip(s string) string { + // Replace all \r\n with \n + s = strings.ReplaceAll(s, "\r\n", "\n") + return ansi.Strip(s) +}