mirror of
https://github.com/johnkerl/miller.git
synced 2026-07-18 00:45:47 +00:00
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:
parent
1b69ee1588
commit
e0cf596853
10 changed files with 244 additions and 5 deletions
|
|
@ -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() {
|
||||
|
|
|
|||
|
|
@ -101,6 +101,7 @@ type TWriterOptions struct {
|
|||
BarredUseUnicode bool
|
||||
RightAlignedPPRINTOutput bool
|
||||
RightAlignedXTABOutput bool
|
||||
MarkdownAlignedOutput bool
|
||||
|
||||
// JSON output: --jlistwrap on, --jvstack on
|
||||
// JSON Lines output: --jlistwrap off, --jvstack off
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue