提交 9ae935bb 编写于 作者: kingreatwill's avatar kingreatwill

完善.

上级 f2f2fa4d
https://gocn.vip/topics/10141
https://github.com/austingebauer/go-leetcode
\ No newline at end of file
...@@ -2,6 +2,7 @@ go mod 1.13 ...@@ -2,6 +2,7 @@ go mod 1.13
https://github.com/golang/go/wiki/Modules https://github.com/golang/go/wiki/Modules
https://github.com/golang/proposal/blob/master/design/24301-versioned-go.md https://github.com/golang/proposal/blob/master/design/24301-versioned-go.md
[goproxy.cn 现已推出首个 Go 模块代理统计数据 API](https://mp.weixin.qq.com/s/ZtQJE-Vv_Ke8SjhrzBoGcw)
## 核心文件:go.mod ## 核心文件:go.mod
``` ```
......
...@@ -5,4 +5,5 @@ go 1.14 ...@@ -5,4 +5,5 @@ go 1.14
require ( require (
github.com/JohannesKaufmann/html-to-markdown v0.0.0-20200323205911-a6f44902a8f4 github.com/JohannesKaufmann/html-to-markdown v0.0.0-20200323205911-a6f44902a8f4
github.com/PuerkitoBio/goquery v1.5.1 github.com/PuerkitoBio/goquery v1.5.1
golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e // indirect
) )
...@@ -10,7 +10,11 @@ golang.org/x/net v0.0.0-20200202094626-16171245cfb2 h1:CCH4IOTTfewWjGOlSp+zGcjut ...@@ -10,7 +10,11 @@ golang.org/x/net v0.0.0-20200202094626-16171245cfb2 h1:CCH4IOTTfewWjGOlSp+zGcjut
golang.org/x/net v0.0.0-20200202094626-16171245cfb2/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200202094626-16171245cfb2/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20200320220750-118fecf932d8 h1:1+zQlQqEEhUeStBTi653GZAnAuivZq/2hz+Iz+OP7rg= golang.org/x/net v0.0.0-20200320220750-118fecf932d8 h1:1+zQlQqEEhUeStBTi653GZAnAuivZq/2hz+Iz+OP7rg=
golang.org/x/net v0.0.0-20200320220750-118fecf932d8/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200320220750-118fecf932d8/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e h1:3G+cUijn7XD+S4eJFddp53Pv7+slrESplyjG25HgL+k=
golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v2 v2.2.8 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10=
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
package main package main
import ( import (
md "github.com/JohannesKaufmann/html-to-markdown"
"github.com/JohannesKaufmann/html-to-markdown/plugin"
"github.com/PuerkitoBio/goquery"
"testing" "testing"
) )
var html =`<p>1. xxx <br/>2. xxxx<br/>3. xxx</p><p><span class="img-wrap"><img src="xxx"></span><br>4. golang<br>a. xx<br>b. xx</p> jmap –histo[:live]`
var html2 =`<code>last_30_days</code>`
func Test_md(t *testing.T) {
//opt := &md.Options{
// StrongDelimiter: "__", // default: **
//}
var converter = md.NewConverter("", true, nil)
newline := md.Rule{
Filter: []string{"br"}, // register <br>
Replacement: func(content string, selec *goquery.Selection, opt *md.Options) *string {
return md.String("\n") // return markdown
},
}
converter.Use(plugin.GitHubFlavored())
converter.Use(plugin.TaskListItems())
converter.AddRules(plugin.EXPERIMENTAL_Table...)
converter.AddRules(newline)
md_str,_ := converter.ConvertString(html2)
println(md_str)
}
func Test_segmentfault(t *testing.T) { func Test_segmentfault(t *testing.T) {
do("https://segmentfault.com/a/1190000014395186", "", "") do("https://segmentfault.com/a/1190000014395186", "", "")
// html2md.exe https://segmentfault.com/a/1190000014395186 // html2md.exe https://segmentfault.com/a/1190000014395186
...@@ -22,4 +50,14 @@ func Test_blog_csdn(t *testing.T) { ...@@ -22,4 +50,14 @@ func Test_blog_csdn(t *testing.T) {
func Test_jianshu(t *testing.T) { func Test_jianshu(t *testing.T) {
do("https://www.jianshu.com/p/16719baa1713", "", "") do("https://www.jianshu.com/p/16719baa1713", "", "")
// html2md.exe https://www.jianshu.com/p/16719baa1713 // html2md.exe https://www.jianshu.com/p/16719baa1713
}
func Test_mpweixin(t *testing.T) {
do("https://mp.weixin.qq.com/s?__biz=MzAxMTA4Njc0OQ==&mid=2651437583&idx=2&sn=ddb41d563ce289aea4ef50e57fa58acd&chksm=80bb64fdb7ccedeb5ee8210371ae88ff871173160b75b55bb8878c3a30cf0935cbc1fad32ebb&scene=21#wechat_redirect", "", "")
// html2md.exe https://mp.weixin.qq.com/s/UMv7C2KkEdKfEgIZxOksbg
}
func Test_oschina(t *testing.T) {
do("https://www.oschina.net/news/114446/benchmark-openjdk-corretto-graalvm", "", "")
// html2md.exe https://www.oschina.net/news/114446/benchmark-openjdk-corretto-graalvm
} }
\ No newline at end of file
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册