mirror of
https://github.com/foomo/keel.git
synced 2025-10-16 12:35:34 +00:00
40 lines
729 B
Go
40 lines
729 B
Go
package markdown
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
markdowntable "github.com/fbiville/markdown-table-formatter/pkg/markdown"
|
|
)
|
|
|
|
type Markdown struct {
|
|
value string
|
|
}
|
|
|
|
func (s *Markdown) Println(a ...any) {
|
|
s.value += fmt.Sprintln(a...)
|
|
}
|
|
|
|
func (s *Markdown) Printf(format string, a ...any) {
|
|
s.Println(fmt.Sprintf(format, a...))
|
|
}
|
|
|
|
func (s *Markdown) Print(a ...any) {
|
|
s.value += fmt.Sprint(a...)
|
|
}
|
|
|
|
func (s *Markdown) String() string {
|
|
return s.value
|
|
}
|
|
|
|
func (s *Markdown) Table(headers []string, rows [][]string) {
|
|
table, err := markdowntable.NewTableFormatterBuilder().
|
|
WithAlphabeticalSortIn(markdowntable.ASCENDING_ORDER).
|
|
WithPrettyPrint().
|
|
Build(headers...).
|
|
Format(rows)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
s.Print(table)
|
|
}
|