From 5e6739f34587d01005c8c782ab9f386e18e28a3f Mon Sep 17 00:00:00 2001 From: Joseph Cumines Date: Sun, 3 Feb 2019 10:40:00 +1000 Subject: [PATCH] doc(Parse) --- htmlutil.go | 2 ++ internal.go | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/htmlutil.go b/htmlutil.go index 1eb2d7c..c096443 100755 --- a/htmlutil.go +++ b/htmlutil.go @@ -35,6 +35,8 @@ type Node struct { Match *Node } +// Parse first performs html.Parse, parsing through any errors, before applying a find to the resulting Node (wrapped +// like `Node{Data: node}`), returning the first matching Node, or an error, if no matches were found func Parse(r io.Reader, filters ...func(node Node) bool) (Node, error) { if node, err := html.Parse(r); err != nil { return Node{}, err diff --git a/internal.go b/internal.go index 02ba8dd..7f30835 100755 --- a/internal.go +++ b/internal.go @@ -225,7 +225,7 @@ func siblingLength(node Node, filters ...func(node Node) bool) (v int) { // count previous siblings matching filters v = siblingIndex(node, filters...) // count this node (if not empty) and filtered next siblings - for node := node; node.Data != nil; node = node.NextSibling(filters...) { + for ; node.Data != nil; node = node.NextSibling(filters...) { v++ } return