diff options
| author | suntong <[email protected]> | 2023-06-15 17:31:56 -0400 |
|---|---|---|
| committer | GitHub <[email protected]> | 2023-06-15 17:31:56 -0400 |
| commit | c8a4f8f1f04e2a6e4f5f916e9a40657c65364d19 (patch) | |
| tree | e18c23ac44ea5a9ac5e71b446e30aa5ea5d437b9 | |
| parent | Update bug-report-template.md (diff) | |
| parent | <br> to newline plugin (diff) | |
| download | html2md-c8a4f8f1f04e2a6e4f5f916e9a40657c65364d19.tar.xz html2md-c8a4f8f1f04e2a6e4f5f916e9a40657c65364d19.zip | |
Merge pull request #16 from ImportTaste/master
<br> to newline plugin
| -rw-r--r-- | html2md_cli.yaml | 5 | ||||
| -rw-r--r-- | html2md_cliDef.go | 2 | ||||
| -rw-r--r-- | plugin_brnewline.go | 20 | ||||
| -rw-r--r-- | prop_html2md.go | 3 |
4 files changed, 30 insertions, 0 deletions
diff --git a/html2md_cli.yaml b/html2md_cli.yaml index 7c4ebbc..5dbd4cd 100644 --- a/html2md_cli.yaml +++ b/html2md_cli.yaml @@ -101,6 +101,11 @@ Options: # Plugins + - Name: PluginBrToNewline + Type: bool + Flag: "plugin-br-to-newline" + Usage: Plugin BrToNewline + - Name: PluginConfluenceAttachments Type: bool Flag: "A,plugin-conf-attachment" diff --git a/html2md_cliDef.go b/html2md_cliDef.go index d6abdef..f61bfca 100644 --- a/html2md_cliDef.go +++ b/html2md_cliDef.go @@ -39,6 +39,7 @@ type rootT struct { OptLinkStyle string `cli:"opt-link-style" usage:"Option LinkStyle"` OptLinkReferenceStyle string `cli:"opt-link-reference-style" usage:"Option LinkReferenceStyle"` OptEscapeMode string `cli:"opt-escape-mode" usage:"Option EscapeMode\n"` + PluginBrToNewline bool `cli:"plugin-br-to-newline" usage:"Plugin BrToNewline"` PluginConfluenceAttachments bool `cli:"A,plugin-conf-attachment" usage:"Plugin ConfluenceAttachments"` PluginConfluenceCodeBlock bool `cli:"C,plugin-conf-code" usage:"Plugin ConfluenceCodeBlock"` PluginFrontMatter bool `cli:"F,plugin-frontmatter" usage:"Plugin FrontMatter"` @@ -85,6 +86,7 @@ var root = &cli.Command{ // OptLinkStyle string // OptLinkReferenceStyle string // OptEscapeMode string +// PluginBrToNewline bool // PluginConfluenceAttachments bool // PluginConfluenceCodeBlock bool // PluginFrontMatter bool diff --git a/plugin_brnewline.go b/plugin_brnewline.go new file mode 100644 index 0000000..0e5c6b0 --- /dev/null +++ b/plugin_brnewline.go @@ -0,0 +1,20 @@ +package main + +import ( + md "github.com/JohannesKaufmann/html-to-markdown" + "github.com/PuerkitoBio/goquery" +) + +// TaskListItems converts checkboxes into task list items. +func BrToNewline() md.Plugin { + return func(c *md.Converter) []md.Rule { + return []md.Rule{ + { + Filter: []string{"br"}, + Replacement: func(content string, selec *goquery.Selection, opt *md.Options) *string { + return md.String("\n") + }, + }, + } + } +}
\ No newline at end of file diff --git a/prop_html2md.go b/prop_html2md.go index 26d4632..0d80e53 100644 --- a/prop_html2md.go +++ b/prop_html2md.go @@ -98,6 +98,9 @@ func handleOptions(opt *md.Options, rootArgv *rootT) *md.Options { } func handlePlugins(conv *md.Converter, rootArgv *rootT) *md.Converter { + if rootArgv.PluginBrToNewline { + conv.Use(BrToNewline()) + } if rootArgv.PluginConfluenceAttachments { conv.Use(plugin.ConfluenceAttachments()) } |