diff --git a/docs/src/file-formats.md b/docs/src/file-formats.md index 59cb6d80c..cd24cb09a 100644 --- a/docs/src/file-formats.md +++ b/docs/src/file-formats.md @@ -549,7 +549,7 @@ which renders like this when dropped into various web tools (e.g. github.comment  As of Miller 4.3.0, markdown format is supported only for output, not input; as of Miller 6.11.0, markdown format -is supported for input as well. +is supported for input as well. Use `--imd` for markdown input, `--omd` for markdown output, or `--md` for both. By default, markdown cells are not padded -- which renders identically in a Markdown viewer but can be awkward to read or maintain as raw text. Use `--omd-aligned` to pad each column @@ -569,6 +569,13 @@ do not need to pass `--omd` in addition: | wye | pan | 5 | 0.573288 | 0.863624 | +Use `--md-aligned` to set both input and output to markdown with aligned output. This implies `--md`, so you +do not need to pass `--md` in addition: + +
+mlr --md-aligned cat data/small ++ ## XTAB: Vertical tabular This is perhaps most useful for looking a very wide and/or multi-column data which causes line-wraps on the screen (but see also diff --git a/docs/src/file-formats.md.in b/docs/src/file-formats.md.in index bbb748981..00f3dc908 100644 --- a/docs/src/file-formats.md.in +++ b/docs/src/file-formats.md.in @@ -221,7 +221,7 @@ which renders like this when dropped into various web tools (e.g. github.comment  As of Miller 4.3.0, markdown format is supported only for output, not input; as of Miller 6.11.0, markdown format -is supported for input as well. +is supported for input as well. Use `--imd` for markdown input, `--omd` for markdown output, or `--md` for both. By default, markdown cells are not padded -- which renders identically in a Markdown viewer but can be awkward to read or maintain as raw text. Use `--omd-aligned` to pad each column @@ -232,6 +232,13 @@ GENMD-RUN-COMMAND mlr --omd-aligned cat data/small GENMD-EOF +Use `--md-aligned` to set both input and output to markdown with aligned output. This implies `--md`, so you +do not need to pass `--md` in addition: + +GENMD-RUN-COMMAND +mlr --md-aligned cat data/small +GENMD-EOF + ## XTAB: Vertical tabular This is perhaps most useful for looking a very wide and/or multi-column data which causes line-wraps on the screen (but see also diff --git a/docs/src/manpage.md b/docs/src/manpage.md index 31717b833..09a580ada 100644 --- a/docs/src/manpage.md +++ b/docs/src/manpage.md @@ -446,6 +446,8 @@ This is simply a copy of what you should see on running `man mlr` at a command p --iyaml Use YAML format for input data. --json or -j or --j2j Use JSON format for input and output data. --jsonl or --l2l Use JSON Lines format for input and output data. + --md or --markdown Use markdown-tabular format for input and output + data. --nidx or --n2n Use NIDX format for input and output data. --oasv or --oasvlite Use ASV format for output data. --ocsv Use CSV format for output data. @@ -568,6 +570,10 @@ This is simply a copy of what you should see on running `man mlr` at a command p 1mMARKDOWN-ONLY FLAGS0m These are flags which are applicable to markdown-tabular format. + --md-aligned or --markdown-aligned + Use markdown-tabular format for input and output + data, with left-justified and padded columns. Implies + --md, so you do not need to also pass --md. --omd-aligned or --omarkdown-aligned For markdown-tabular output, left-justify cells and pad each column to a uniform width, making the raw @@ -1380,6 +1386,8 @@ This is simply a copy of what you should see on running `man mlr` at a command p Options: -g {a,b,c} Optional group-by-field names for head counts, e.g. a,b,c. -n {n} Head-count to print. Default 10. + A negative count, e.g. -n -2, passes through all but the last n records, + optionally by category. -h|--help Show this message. 1mhistogram0m @@ -2225,8 +2233,11 @@ This is simply a copy of what you should see on running `man mlr` at a command p Usage: mlr tail [options] Passes through the last n records, optionally by category. Options: - -g {a,b,c} Optional group-by-field names for head counts, e.g. a,b,c. - -n {n} Head-count to print. Default 10. + -g {a,b,c} Optional group-by-field names for tail counts, e.g. a,b,c. + -n {n} Tail-count to print. Default 10. + A leading '+' means start at the nth record rather than print + the last n: e.g. -n +3 passes through all but the first 2 + records, optionally by category. -h|--help Show this message. 1mtee0m @@ -3852,5 +3863,5 @@ This is simply a copy of what you should see on running `man mlr` at a command p MIME Type for Comma-Separated Values (CSV) Files, the Miller docsite https://miller.readthedocs.io - 2026-06-19 4mMILLER24m(1) + 2026-06-24 4mMILLER24m(1) diff --git a/docs/src/manpage.txt b/docs/src/manpage.txt index 4b4d56236..c3849c6fc 100644 --- a/docs/src/manpage.txt +++ b/docs/src/manpage.txt @@ -425,6 +425,8 @@ --iyaml Use YAML format for input data. --json or -j or --j2j Use JSON format for input and output data. --jsonl or --l2l Use JSON Lines format for input and output data. + --md or --markdown Use markdown-tabular format for input and output + data. --nidx or --n2n Use NIDX format for input and output data. --oasv or --oasvlite Use ASV format for output data. --ocsv Use CSV format for output data. @@ -547,6 +549,10 @@ 1mMARKDOWN-ONLY FLAGS0m These are flags which are applicable to markdown-tabular format. + --md-aligned or --markdown-aligned + Use markdown-tabular format for input and output + data, with left-justified and padded columns. Implies + --md, so you do not need to also pass --md. --omd-aligned or --omarkdown-aligned For markdown-tabular output, left-justify cells and pad each column to a uniform width, making the raw @@ -1359,6 +1365,8 @@ Options: -g {a,b,c} Optional group-by-field names for head counts, e.g. a,b,c. -n {n} Head-count to print. Default 10. + A negative count, e.g. -n -2, passes through all but the last n records, + optionally by category. -h|--help Show this message. 1mhistogram0m @@ -2204,8 +2212,11 @@ Usage: mlr tail [options] Passes through the last n records, optionally by category. Options: - -g {a,b,c} Optional group-by-field names for head counts, e.g. a,b,c. - -n {n} Head-count to print. Default 10. + -g {a,b,c} Optional group-by-field names for tail counts, e.g. a,b,c. + -n {n} Tail-count to print. Default 10. + A leading '+' means start at the nth record rather than print + the last n: e.g. -n +3 passes through all but the first 2 + records, optionally by category. -h|--help Show this message. 1mtee0m @@ -3831,4 +3842,4 @@ MIME Type for Comma-Separated Values (CSV) Files, the Miller docsite https://miller.readthedocs.io - 2026-06-19 4mMILLER24m(1) + 2026-06-24 4mMILLER24m(1) diff --git a/docs/src/reference-main-flag-list.md b/docs/src/reference-main-flag-list.md index 73d44f64c..d4e6012b5 100644 --- a/docs/src/reference-main-flag-list.md +++ b/docs/src/reference-main-flag-list.md @@ -181,6 +181,7 @@ are overridden in all cases by setting output format to `format2`. * `--iyaml`: Use YAML format for input data. * `--json or -j or --j2j`: Use JSON format for input and output data. * `--jsonl or --l2l`: Use JSON Lines format for input and output data. +* `--md or --markdown`: Use markdown-tabular format for input and output data. * `--nidx or --n2n`: Use NIDX format for input and output data. * `--oasv or --oasvlite`: Use ASV format for output data. * `--ocsv`: Use CSV format for output data. @@ -289,6 +290,7 @@ These are flags which are applicable to markdown-tabular format. **Flags:** +* `--md-aligned or --markdown-aligned`: Use markdown-tabular format for input and output data, with left-justified and padded columns. Implies --md, so you do not need to also pass --md. * `--omd-aligned or --omarkdown-aligned`: 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. ## Miscellaneous flags diff --git a/man/manpage.txt b/man/manpage.txt index 4b4d56236..c3849c6fc 100644 --- a/man/manpage.txt +++ b/man/manpage.txt @@ -425,6 +425,8 @@ --iyaml Use YAML format for input data. --json or -j or --j2j Use JSON format for input and output data. --jsonl or --l2l Use JSON Lines format for input and output data. + --md or --markdown Use markdown-tabular format for input and output + data. --nidx or --n2n Use NIDX format for input and output data. --oasv or --oasvlite Use ASV format for output data. --ocsv Use CSV format for output data. @@ -547,6 +549,10 @@ 1mMARKDOWN-ONLY FLAGS0m These are flags which are applicable to markdown-tabular format. + --md-aligned or --markdown-aligned + Use markdown-tabular format for input and output + data, with left-justified and padded columns. Implies + --md, so you do not need to also pass --md. --omd-aligned or --omarkdown-aligned For markdown-tabular output, left-justify cells and pad each column to a uniform width, making the raw @@ -1359,6 +1365,8 @@ Options: -g {a,b,c} Optional group-by-field names for head counts, e.g. a,b,c. -n {n} Head-count to print. Default 10. + A negative count, e.g. -n -2, passes through all but the last n records, + optionally by category. -h|--help Show this message. 1mhistogram0m @@ -2204,8 +2212,11 @@ Usage: mlr tail [options] Passes through the last n records, optionally by category. Options: - -g {a,b,c} Optional group-by-field names for head counts, e.g. a,b,c. - -n {n} Head-count to print. Default 10. + -g {a,b,c} Optional group-by-field names for tail counts, e.g. a,b,c. + -n {n} Tail-count to print. Default 10. + A leading '+' means start at the nth record rather than print + the last n: e.g. -n +3 passes through all but the first 2 + records, optionally by category. -h|--help Show this message. 1mtee0m @@ -3831,4 +3842,4 @@ MIME Type for Comma-Separated Values (CSV) Files, the Miller docsite https://miller.readthedocs.io - 2026-06-19 4mMILLER24m(1) + 2026-06-24 4mMILLER24m(1) diff --git a/man/mlr.1 b/man/mlr.1 index afd539e49..604f0bcda 100644 --- a/man/mlr.1 +++ b/man/mlr.1 @@ -2,12 +2,12 @@ .\" Title: mlr .\" Author: [see the "AUTHOR" section] .\" Generator: ./mkman.rb -.\" Date: 2026-06-19 +.\" Date: 2026-06-24 .\" Manual: \ \& .\" Source: \ \& .\" Language: English .\" -.TH "MILLER" "1" "2026-06-19" "\ \&" "\ \&" +.TH "MILLER" "1" "2026-06-24" "\ \&" "\ \&" .\" ----------------------------------------------------------------- .\" * Portability definitions .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -513,6 +513,8 @@ are overridden in all cases by setting output format to `format2`. --iyaml Use YAML format for input data. --json or -j or --j2j Use JSON format for input and output data. --jsonl or --l2l Use JSON Lines format for input and output data. +--md or --markdown Use markdown-tabular format for input and output + data. --nidx or --n2n Use NIDX format for input and output data. --oasv or --oasvlite Use ASV format for output data. --ocsv Use CSV format for output data. @@ -675,6 +677,10 @@ They are accepted as no-op flags in order to keep old scripts from breaking. .nf These are flags which are applicable to markdown-tabular format. +--md-aligned or --markdown-aligned + Use markdown-tabular format for input and output + data, with left-justified and padded columns. Implies + --md, so you do not need to also pass --md. --omd-aligned or --omarkdown-aligned For markdown-tabular output, left-justify cells and pad each column to a uniform width, making the raw @@ -1697,6 +1703,8 @@ Without -g, ceases consuming more input (i.e. is fast) when n records have been Options: -g {a,b,c} Optional group-by-field names for head counts, e.g. a,b,c. -n {n} Head-count to print. Default 10. + A negative count, e.g. -n -2, passes through all but the last n records, + optionally by category. -h|--help Show this message. .fi .if n \{\ @@ -2764,8 +2772,11 @@ Options: Usage: mlr tail [options] Passes through the last n records, optionally by category. Options: --g {a,b,c} Optional group-by-field names for head counts, e.g. a,b,c. --n {n} Head-count to print. Default 10. +-g {a,b,c} Optional group-by-field names for tail counts, e.g. a,b,c. +-n {n} Tail-count to print. Default 10. + A leading '+' means start at the nth record rather than print + the last n: e.g. -n +3 passes through all but the first 2 + records, optionally by category. -h|--help Show this message. .fi .if n \{\ diff --git a/pkg/cli/option_parse.go b/pkg/cli/option_parse.go index 0c994578f..9f81a24a3 100644 --- a/pkg/cli/option_parse.go +++ b/pkg/cli/option_parse.go @@ -609,6 +609,20 @@ var MarkdownOnlyFlagSection = FlagSection{ *pargi += 1 }, }, + + { + name: "--md-aligned", + altNames: []string{"--markdown-aligned"}, + help: "Use markdown-tabular format for input and output data, with " + + "left-justified and padded columns. Implies --md, so you do not " + + "need to also pass --md.", + parser: func(args []string, argc int, pargi *int, options *TOptions) { + options.ReaderOptions.InputFileFormat = "markdown" + options.WriterOptions.OutputFileFormat = "markdown" + options.WriterOptions.MarkdownAlignedOutput = true + *pargi += 1 + }, + }, }, } @@ -1058,6 +1072,17 @@ var FileFormatFlagSection = FlagSection{ }, }, + { + name: "--md", + altNames: []string{"--markdown"}, + help: "Use markdown-tabular format for input and output data.", + parser: func(args []string, argc int, pargi *int, options *TOptions) { + options.ReaderOptions.InputFileFormat = "markdown" + options.WriterOptions.OutputFileFormat = "markdown" + *pargi += 1 + }, + }, + { name: "--odkvp", help: "Use DKVP format for output data.",