/html2md

A Go library for converting html to markdown

Primary LanguageGo

Html2md is an implementation of converting html to markdown for Go.

Installation

If you have gopm installed,

gopm get github.com/lunny/html2md

Or

go get github.com/lunny/html2md

Usage

  • Html2md has some html tag Rules. For simple use, just use
    md := html2md.Convert(html)
  • If you want to use your self Rule. 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(conent string) string {
    return strings.ToLower(content)
})

Documents

LICENSE

BSD License http://creativecommons.org/licenses/BSD/