Documentation
¶
Overview ¶
Package gmdtable converts ordered column headers and map-backed row data into Markdown tables.
Convert uses the header slice as both the table schema and the column order. Cell values are formatted with fmt's default representation, then structural Markdown table characters are escaped. The package performs no I/O and has no runtime dependencies outside the Go standard library.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Convert ¶
Convert returns a Markdown table containing headers and data.
The order of headers determines the column order. Each row is read by header key, and values use fmt's default formatting. Pipes, backslashes, and line breaks are escaped so they remain within their cells. Columns are padded to their widest cell. Convert returns an error when headers or data is empty.
Example ¶
package main
import (
"fmt"
"github.com/tzfqh/gmdtable"
)
func main() {
headers := []string{"Name", "Language"}
data := []map[string]interface{}{{"Name": "gmdtable", "Language": "Go"}}
table, err := gmdtable.Convert(headers, data)
if err != nil {
panic(err)
}
fmt.Println(table)
}
Output: | Name | Language | | :------- | :------- | | gmdtable | Go |
Types ¶
This section is empty.
Directories
¶
| Path | Synopsis |
|---|---|
|
cmd
|
|
|
sitegen
command
Command sitegen builds, validates, and previews the generated GitHub Pages website.
|
Command sitegen builds, validates, and previews the generated GitHub Pages website. |
|
examples
|
|
|
basic
command
Command basic demonstrates the public Markdown-table conversion API.
|
Command basic demonstrates the public Markdown-table conversion API. |
|
internal
|
|