fix #50: remove excess spaces in normal ascii table output mode

This commit is contained in:
2026-02-19 13:50:21 +01:00
parent 2122805301
commit d6dec219a8
2 changed files with 37 additions and 29 deletions

View File

@@ -255,7 +255,15 @@ func printASCIIData(writer io.Writer, conf cfg.Config, data *Tabdata) {
log.Fatalf("Failed to render table: %s", err) log.Fatalf("Failed to render table: %s", err)
} }
output(writer, conf, color.Sprint(colorizeData(conf, tableString.String()))) // we need to trim our output here, because tablewriter appends
// excess whitespace to our rows.
cleanedString := &strings.Builder{}
for _, row := range strings.Split(tableString.String(), "\n") {
cleanedString.WriteString(strings.TrimSpace(row))
cleanedString.WriteString("\n")
}
output(writer, conf, color.Sprint(colorizeData(conf, cleanedString.String())))
} }
/* /*

View File

@@ -23,8 +23,8 @@ import (
"strings" "strings"
"testing" "testing"
"github.com/stretchr/testify/assert"
"codeberg.org/scip/tablizer/cfg" "codeberg.org/scip/tablizer/cfg"
"github.com/stretchr/testify/assert"
) )
func newData() Tabdata { func newData() Tabdata {