html2md

package
v0.0.0-...-2bc18d8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 14, 2017 License: BSD-2-Clause Imports: 4 Imported by: 0

README

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/

Documentation

Index

Constants

View Source
const (
	Foreign = iota
	Void
)

Variables

This section is empty.

Functions

func AddConvert

func AddConvert(f func(string) string)

func AddRule

func AddRule(name string, rule *Rule)

func AttrRegExp

func AttrRegExp(attr string) *regexp.Regexp

func Convert

func Convert(content string) string

func Remove

func Remove(ct, tag string) string

Types

type ReplaceFunc

type ReplaceFunc func(string, []string) string

type Rule

type Rule struct {
	Patterns    []string
	Tp          int
	Replacement ReplaceFunc
}

func A

func A() *Rule

func B

func B() *Rule

func Br

func Br() *Rule

func Code

func Code() *Rule

func H

func H() *Rule

func Hr

func Hr() *Rule

func I

func I() *Rule

func Img

func Img() *Rule

func P

func P() *Rule

func SameRule

func SameRule(tag string, tp int) *Rule

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL