diff options
| author | Tong Sun <[email protected]> | 2023-05-03 12:35:08 -0400 |
|---|---|---|
| committer | Tong Sun <[email protected]> | 2023-05-03 12:35:08 -0400 |
| commit | 098407f5d50b96b8bbb94bc9c03a8ba7bde073ad (patch) | |
| tree | d1e59d7acdde0f110982f6a5b3e50e5b30723e13 /prop_html2md.go | |
| parent | - [+] add excluding control wireframe (diff) | |
| download | html2md-098407f5d50b96b8bbb94bc9c03a8ba7bde073ad.tar.xz html2md-098407f5d50b96b8bbb94bc9c03a8ba7bde073ad.zip | |
- [+] implement excluding control. close #6
Diffstat (limited to 'prop_html2md.go')
| -rw-r--r-- | prop_html2md.go | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/prop_html2md.go b/prop_html2md.go index b32f90f..26d4632 100644 --- a/prop_html2md.go +++ b/prop_html2md.go @@ -35,6 +35,17 @@ func Html2md(ctx *cli.Context) error { doc, err := goquery.NewDocumentFromReader(rootArgv.Filei) clis.AbortOn("Reading file with goquery", err) content := doc.Find(rootArgv.Sel) + if rootArgv.ExclChildren { + content = content.Children().Remove().End() + // h, _ := goquery.OuterHtml(content) + // clis.Verbose(3, "%#v\n", h) + } else if len(rootArgv.Excl) != 0 { + for _, ex := range rootArgv.Excl { + content = content.Find(ex).Remove().End() + h, _ := content.Html() + clis.Verbose(5, "%#v\n", h) + } + } domain, url := rootArgv.Domain, rootArgv.Filei.Name() if domain == "" && regexp.MustCompile(`(?i)^http`).MatchString(url) { |