mirror of
https://github.com/cwinfo/matterbridge.git
synced 2025-07-03 11:57:45 +00:00
Update vendor (#1297)
This commit is contained in:
38
vendor/github.com/mattn/godown/godown.go
generated
vendored
38
vendor/github.com/mattn/godown/godown.go
generated
vendored
@ -346,6 +346,22 @@ func walk(node *html.Node, w io.Writer, nest int, option *Option) {
|
||||
fmt.Fprint(w, "\n\n")
|
||||
}
|
||||
default:
|
||||
if option == nil || option.CustomRules == nil {
|
||||
walk(c, w, nest, option)
|
||||
break
|
||||
}
|
||||
|
||||
foundCustom := false
|
||||
for _, cr := range option.CustomRules {
|
||||
if tag, customWalk := cr.Rule(walk); strings.ToLower(c.Data) == tag {
|
||||
customWalk(c, w, nest, option)
|
||||
foundCustom = true
|
||||
}
|
||||
}
|
||||
|
||||
if foundCustom {
|
||||
break
|
||||
}
|
||||
walk(c, w, nest, option)
|
||||
}
|
||||
default:
|
||||
@ -354,11 +370,27 @@ func walk(node *html.Node, w io.Writer, nest int, option *Option) {
|
||||
}
|
||||
}
|
||||
|
||||
// WalkFunc type is an signature for functions traversing HTML nodes
|
||||
type WalkFunc func(node *html.Node, w io.Writer, nest int, option *Option)
|
||||
|
||||
// CustomRule is an interface to define custom conversion rules
|
||||
//
|
||||
// Rule method accepts `next WalkFunc` as an argument, which `customRule` should call
|
||||
// to let walk function continue parsing the content inside the HTML tag.
|
||||
// It returns a tagName to indicate what HTML element this `customRule` handles and the `customRule`
|
||||
// function itself, where conversion logic should reside.
|
||||
//
|
||||
// See example TestRule implementation in godown_test.go
|
||||
type CustomRule interface {
|
||||
Rule(next WalkFunc) (tagName string, customRule WalkFunc)
|
||||
}
|
||||
|
||||
// Option is optional information for Convert.
|
||||
type Option struct {
|
||||
GuessLang func(string) (string, error)
|
||||
Script bool
|
||||
Style bool
|
||||
GuessLang func(string) (string, error)
|
||||
Script bool
|
||||
Style bool
|
||||
CustomRules []CustomRule
|
||||
}
|
||||
|
||||
// Convert convert HTML to Markdown. Read HTML from r and write to w.
|
||||
|
Reference in New Issue
Block a user