Files
sift/vendor/github.com/JohannesKaufmann/html-to-markdown/v2/internal/domutils/redundant.go
T
kyle 9444a35322 p1: /v2/scrape, /v1/fetch, auth, CLI, contract tests
Single Fetcher.Fetch on the Guard that holds DenyPrefixes. skipTlsVerification
is ignored. No 502. keys add writes the secret only to --out. Release binary
has no -test-allow-prefix.
2026-09-22 21:54:01 -07:00

30 lines
525 B
Go

package domutils
import (
"github.com/JohannesKaufmann/dom"
"golang.org/x/net/html"
)
func RemoveRedundant(doc *html.Node, matchFn func(*html.Node, *html.Node) bool) {
for _, node := range dom.AllNodes(doc) {
if hasSameTypeAncestor(node, matchFn) {
dom.UnwrapNode(node)
}
}
}
func hasSameTypeAncestor(n *html.Node, matchFn func(*html.Node, *html.Node) bool) bool {
if !matchFn(n, n) {
return false
}
for p := n.Parent; p != nil; p = p.Parent {
if matchFn(n, p) {
return true
}
}
return false
}