Html2md is a Go library for converting html to markdown.
If you have gopm installed,
gopm get github.com/lunny/html2md
Or
go get github.com/lunny/html2md
- Html2md already has some built-in html tag rules. For basic use:
md := html2md.Convert(html)
- If you want to add your own rules, you can
html2md.AddRule(&html2md.Rule{
patterns: []string{"hr"},
tp: Void,
replacement: func(innerHTML string, attrs []string) string {
return "\n\n* * *\n"
},
})
or
html2md.AddConvert(func(content string) string {
return strings.ToLower(content)
})
BSD License http://creativecommons.org/licenses/BSD/