Skip to content

Commit

Permalink
table: fix documentation for merges (#296)
Browse files Browse the repository at this point in the history
  • Loading branch information
jedib0t committed Jan 29, 2024
1 parent cc6c24d commit 7206de6
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 10 deletions.
3 changes: 1 addition & 2 deletions table/README.md
Expand Up @@ -206,7 +206,7 @@ it specifically for each row/column using `RowConfig` or `ColumnConfig`.

t := table.NewWriter()
t.AppendHeader(table.Row{"Node IP", "Pods", "Namespace", "Container", "RCE", "RCE"}, rowConfigAutoMerge)
t.AppendHeader(table.Row{"", "", "", "", "EXE", "RUN"})
t.AppendHeader(table.Row{"Node IP", "Pods", "Namespace", "Container", "EXE", "RUN"})
t.AppendRow(table.Row{"1.1.1.1", "Pod 1A", "NS 1A", "C 1", "Y", "Y"}, rowConfigAutoMerge)
t.AppendRow(table.Row{"1.1.1.1", "Pod 1A", "NS 1A", "C 2", "Y", "N"}, rowConfigAutoMerge)
t.AppendRow(table.Row{"1.1.1.1", "Pod 1A", "NS 1B", "C 3", "N", "N"}, rowConfigAutoMerge)
Expand All @@ -224,7 +224,6 @@ it specifically for each row/column using `RowConfig` or `ColumnConfig`.
{Number: 5, Align: text.AlignCenter, AlignFooter: text.AlignCenter, AlignHeader: text.AlignCenter},
{Number: 6, Align: text.AlignCenter, AlignFooter: text.AlignCenter, AlignHeader: text.AlignCenter},
})
t.SetOutputMirror(os.Stdout)
t.SetStyle(table.StyleLight)
t.Style().Options.SeparateRows = true
fmt.Println(t.Render())
Expand Down
10 changes: 2 additions & 8 deletions table/table.go
@@ -1,7 +1,6 @@
package table

import (
"bufio"
"fmt"
"io"
"strings"
Expand Down Expand Up @@ -690,13 +689,8 @@ func (t *Table) render(out *strings.Builder) string {
outStr := out.String()
if t.supressTrailingSpaces {
var trimmed []string
sc := bufio.NewScanner(strings.NewReader(outStr))
for sc.Scan() {
trimmed = append(trimmed, strings.TrimRightFunc(
sc.Text(), func(r rune) bool {
return unicode.IsSpace(r)
},
))
for _, line := range strings.Split(outStr, "\n") {
trimmed = append(trimmed, strings.TrimRightFunc(line, unicode.IsSpace))
}
outStr = strings.Join(trimmed, "\n")
}
Expand Down

0 comments on commit 7206de6

Please sign in to comment.