diff options
| author | Tong Sun <[email protected]> | 2020-07-26 10:47:41 -0400 |
|---|---|---|
| committer | Tong Sun <[email protected]> | 2020-07-26 10:47:41 -0400 |
| commit | 4ad51ce3fa3ed8530266bd9228f603021354b43d (patch) | |
| tree | e03c021a36e568dc486ae0471694007790fec34c /prop_html2md.go | |
| parent | - [+] refactor func html2md() to prop_html2md.go (diff) | |
| download | html2md-4ad51ce3fa3ed8530266bd9228f603021354b43d.tar.xz html2md-4ad51ce3fa3ed8530266bd9228f603021354b43d.zip | |
- [+] functionality implemented from goquery demo
Diffstat (limited to 'prop_html2md.go')
| -rw-r--r-- | prop_html2md.go | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/prop_html2md.go b/prop_html2md.go index 838122e..d96e921 100644 --- a/prop_html2md.go +++ b/prop_html2md.go @@ -8,7 +8,10 @@ package main import ( "fmt" + "log" + md "github.com/JohannesKaufmann/html-to-markdown" + "github.com/PuerkitoBio/goquery" "github.com/mkideal/cli" ) @@ -20,5 +23,17 @@ func html2md(ctx *cli.Context) error { ctx.JSON(ctx.Argv()) fmt.Println() + url := "https://blog.golang.org/godoc-documenting-go-code" + doc, err := goquery.NewDocument(url) + if err != nil { + log.Fatal(err) + } + content := doc.Find("#content") + + conv := md.NewConverter(md.DomainFromURL(url), true, nil) + markdown := conv.Convert(content) + + fmt.Println(markdown) + return nil } |