Skip to content

Remove ignored child nodes in tree #188

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions htmldoc/document.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,14 @@ func (doc *Document) Parse() {
// Internal recursive function that delves into the node tree and captures
// nodes of interest and node id/names.
func (doc *Document) parseNode(n *html.Node) {
// Ignore this tree if data-proofer-ignore set
if doc.ignoreTagAttribute != "" &&
(AttrPresent(n.Attr, doc.ignoreTagAttribute) || ClassPresent(n.Attr, doc.ignoreTagAttribute)) {
// Remove this tree and ignore if data-proofer-ignore set
if doc.ignoreTagAttribute != "" &&
(AttrPresent(n.Attr, doc.ignoreTagAttribute) || ClassPresent(n.Attr, doc.ignoreTagAttribute)) {
var nextSibling *html.Node
for c := n.FirstChild; c != nil; c = nextSibling {
nextSibling = c.NextSibling
n.RemoveChild(c)
}
return
}

Expand Down