// convert nodes to /x/net/html.Node siblings. // Document node children are integrated as siblings. // Nils are skipped. func (s Siblings) convert(parent *html.Node) (first, last *html.Node) { var prev *html.Node for _, n := range s { if n == nil { continue } if n.Type == html.DocumentNode { start, end := n.Children.convert(parent) if prev != nil { prev.NextSibling = start } else { first = start } prev = end continue } h := n.convert() h.Parent = parent h.PrevSibling = prev if prev != nil { prev.NextSibling = h } else { first = h } prev = h } return first, prev }