Skip to content

Commit 9c53576

Browse files
cli: add tableNewlineBehavior to options (#160)
1 parent 64e925c commit 9c53576

File tree

5 files changed

+12
-0
lines changed

5 files changed

+12
-0
lines changed

‎cli/html2markdown/cmd/cmd_convert.go‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ func (cli *CLI) convert(input []byte) ([]byte, error) {
111111
table.WithHeaderPromotion(cli.config.tableHeaderPromotion),
112112
table.WithSpanCellBehavior(table.SpanCellBehavior(cli.config.tableSpanCellBehavior)),
113113
table.WithPresentationTables(cli.config.tablePresentationTables),
114+
table.WithNewlineBehavior(table.NewlineBehavior(cli.config.tableNewlineBehavior)),
114115
),
115116
)
116117
}

‎cli/html2markdown/cmd/exec.go‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ type Config struct {
4545
tableHeaderPromotion bool
4646
tableSpanCellBehavior string
4747
tablePresentationTables bool
48+
tableNewlineBehavior string
4849
}
4950

5051
// Release holds the information (from the 3 ldflags) that goreleaser sets.

‎cli/html2markdown/cmd/flags.go‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ func (cli *CLI) initFlags(progname string) {
9393
cli.flags.BoolVar(&cli.config.tableHeaderPromotion, "opt-table-header-promotion", false, "[for --plugin-table] first row should be treated as a header")
9494
cli.flags.StringVar(&cli.config.tableSpanCellBehavior, "opt-table-span-cell-behavior", "", `[for --plugin-table] how colspan/rowspan should be rendered: "empty" or "mirror"`)
9595
cli.flags.BoolVar(&cli.config.tablePresentationTables, "opt-table-presentation-tables", false, `[for --plugin-table] whether tables with role="presentation" should be converted`)
96+
cli.flags.StringVar(&cli.config.tableNewlineBehavior, "opt-table-newline-behavior", "", `[for --plugin-table] how tables containing newlines should be handled: "skip" or "preserve"`)
9697
}
9798

9899
func (cli *CLI) parseFlags(args []string) error {
@@ -116,6 +117,9 @@ func (cli *CLI) parseFlags(args []string) error {
116117
if cli.config.tablePresentationTables && !cli.config.enablePluginTable {
117118
return fmt.Errorf("--opt-table-presentation-tables requires --plugin-table to be enabled")
118119
}
120+
if cli.config.tableNewlineBehavior != "" && !cli.config.enablePluginTable {
121+
return fmt.Errorf("--opt-table-newline-behavior requires --plugin-table to be enabled")
122+
}
119123

120124
// TODO: use constant for flag name & use formatFlag
121125
// var keyStrongDelimiter = "opt-strong-delimiter"

‎cli/html2markdown/cmd/testdata/TestExecute/[general]_help_pipe/stdout.golden‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,9 @@ Use a HTML sanitizer before displaying the HTML in the browser!
7575
--opt-table-header-promotion
7676
[for --plugin-table] first row should be treated as a header
7777

78+
--opt-table-newline-behavior
79+
[for --plugin-table] how tables containing newlines should be handled: "skip" or "preserve"
80+
7881
--opt-table-presentation-tables
7982
[for --plugin-table] whether tables with role="presentation" should be converted
8083

‎cli/html2markdown/cmd/testdata/TestExecute/[general]_help_terminal/stdout.golden‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,9 @@ Use a HTML sanitizer before displaying the HTML in the browser!
7575
--opt-table-header-promotion
7676
[for --plugin-table] first row should be treated as a header
7777

78+
--opt-table-newline-behavior
79+
[for --plugin-table] how tables containing newlines should be handled: "skip" or "preserve"
80+
7881
--opt-table-presentation-tables
7982
[for --plugin-table] whether tables with role="presentation" should be converted
8083

0 commit comments

Comments
 (0)