gmdtable converts ordered Go map data into Markdown tables. The module-root package has one public
function and preserves the header slice as the table's column order.
Go 1.19 or later is supported.
go get github.com/tzfqh/gmdtableimport "github.com/tzfqh/gmdtable"headers := []string{"Name", "Language"}
data := []map[string]interface{}{
{"Name": "gmdtable", "Language": "Go"},
}
table, err := gmdtable.Convert(headers, data)
if err != nil {
log.Fatal(err)
}
fmt.Println(table)The example prints:
| Name | Language |
| :------- | :------- |
| gmdtable | Go |Convert returns an error when headers or data is empty. Values use fmt's default formatting,
missing keys render as <nil>, and structural pipes, backslashes, and line breaks are escaped so the
content remains in its cell. Each column is padded to its widest cell, and its left-aligned separator
uses the same width with at least three hyphens.
Run the complete example with go run ./examples/basic.
- Public website
- Executable examples
- Generated API reference
- pkg.go.dev API documentation
- Basic example
The examples page renders examples/basic/main.go and example_test.go directly from checked-in Go
source. The API page extracts exported declarations and GoDoc from the module-root package.
Run the package checks from the repository root:
gofmt -w .
go mod tidy
go test ./...
go test -race ./...
go vet ./...
go build ./...
go run ./examples/basicGenerate and validate the final GitHub Pages artifact:
go run ./cmd/sitegen build
go run ./cmd/sitegen validatePreview the production-like artifact at http://127.0.0.1:4173/gmdtable/:
go run ./cmd/sitegen previewdist/pages is generated and ignored by Git. Update site.config.json, Go source, templates, or site
assets, then rebuild instead of editing generated Pages files.
The Go package and project-authored website code are available under the MIT License. Vendored Bootstrap notices are in guides/THIRD_PARTY_NOTICES.md.