Skip to content

Commit

Permalink
Merge pull request #17 from lema-ai/main
Browse files Browse the repository at this point in the history
Add SetAutoFormatHeaders to CustomTable
  • Loading branch information
nao1215 authored Mar 29, 2024
2 parents 41ab845 + af7f095 commit 6dca784
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
4 changes: 3 additions & 1 deletion markdown.go
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,8 @@ func (m *Markdown) Table(t TableSet) *Markdown {

type TableOptions struct {
// AutoWrapText is whether to wrap the text automatically.
AutoWrapText bool
AutoWrapText bool
AutoFormatHeaders bool
}

// CustomTable is markdown table. This is so not break the original Table function. with Possible breaking changes.
Expand All @@ -380,6 +381,7 @@ func (m *Markdown) CustomTable(t TableSet, options TableOptions) *Markdown {
table.SetBorders(tablewriter.Border{Left: true, Top: false, Right: true, Bottom: false})
table.SetCenterSeparator("|")
table.SetAutoWrapText(options.AutoWrapText)
table.SetAutoFormatHeaders(options.AutoFormatHeaders)

table.SetHeader(t.Header)
for _, v := range t.Rows {
Expand Down
5 changes: 3 additions & 2 deletions markdown_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -383,10 +383,11 @@ func TestMarkdownCustomTable(t *testing.T) {
Rows: [][]string{{"David", "23"}},
}
m.CustomTable(set, TableOptions{
AutoWrapText: false,
AutoWrapText: false,
AutoFormatHeaders: false,
})
want := []string{
fmt.Sprintf("| NAME | AGE |%s|-------|-----|%s| David | 23 |%s",
fmt.Sprintf("| Name | Age |%s|-------|-----|%s| David | 23 |%s",
lineFeed(), lineFeed(), lineFeed()),
}
got := m.body
Expand Down

0 comments on commit 6dca784

Please sign in to comment.