fix(table): crlf on windows

This commit is contained in:
Ayman Bagabas
2025-02-04 13:27:29 -05:00
parent 061e464a70
commit 3b1b9248be
+9 -2
View File
@@ -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)
}