Add --omd-aligned flag for column-padded markdown output (#2057)

Adds a new Markdown-only flag --omd-aligned (alias --omarkdown-aligned)
that left-justifies cells and pads each column to a uniform width.
The rendered table is unaffected; the goal is readability of the raw
markdown source. The flag implies --omd, so users do not need to pass
both.

Implementation batches records by schema (like pprint), computes max
column widths, then emits header / separator / data rows with bars
vertically aligned. Default markdown writer behavior is unchanged.
This commit is contained in:
John Kerl 2026-05-16 11:41:01 -04:00 committed by GitHub
parent 1b69ee1588
commit e0cf596853
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 244 additions and 5 deletions

View file

@ -117,6 +117,7 @@ var FLAG_TABLE = FlagTable{
&CSVTSVOnlyFlagSection,
&JSONOnlyFlagSection,
&PPRINTOnlyFlagSection,
&MarkdownOnlyFlagSection,
&DKVPOnlyFlagSection,
&CompressedDataFlagSection,
&CommentsInDataFlagSection,
@ -582,6 +583,35 @@ var PPRINTOnlyFlagSection = FlagSection{
},
}
// MARKDOWN-ONLY FLAGS
func MarkdownOnlyPrintInfo() {
fmt.Println("These are flags which are applicable to markdown-tabular format.")
}
func init() { MarkdownOnlyFlagSection.Sort() }
var MarkdownOnlyFlagSection = FlagSection{
name: "Markdown-only flags",
infoPrinter: MarkdownOnlyPrintInfo,
flags: []Flag{
{
name: "--omd-aligned",
altNames: []string{"--omarkdown-aligned"},
help: "For markdown-tabular output, left-justify cells and pad each " +
"column to a uniform width, making the raw markdown source easier " +
"to read and maintain. (The rendered table is unaffected.) Implies " +
"--omd, so you do not need to also pass --omd.",
parser: func(args []string, argc int, pargi *int, options *TOptions) {
options.WriterOptions.OutputFileFormat = "markdown"
options.WriterOptions.MarkdownAlignedOutput = true
*pargi += 1
},
},
},
}
// DKVP-ONLY FLAGS
func DKVPOnlyPrintInfo() {