Skip to content

Commit

Permalink
doc(Parse)
Browse files Browse the repository at this point in the history
  • Loading branch information
joeycumines committed Feb 3, 2019
1 parent f7b7764 commit 5e6739f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 2 additions & 0 deletions htmlutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion internal.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 5e6739f

Please sign in to comment.