A Go library for converting html to markdown
This repository has been archived on 2019-07-12. You can view files and clone it, but cannot push or open issues or pull requests.
Go to file
2018-10-18 15:12:39 +08:00
core.go Export things 2014-06-20 12:43:13 -06:00
html2md_test.go Fix list items ending in space rendering on one line 2018-03-16 13:12:14 +01:00
html2md.go Merge pull request #9 from patcon/fix-regexp-flags 2018-10-18 15:12:39 +08:00
README.md Fixed some typos in README.md 2017-08-11 13:32:00 -04:00

Html2md is a Go library for converting html to markdown.

Installation

If you have gopm installed,

gopm get github.com/lunny/html2md

Or

go get github.com/lunny/html2md

Usage

  • 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)
})

Docs

LICENSE

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