writeNodeText writes the text contained in n and its descendants to b.
(n *html.Node, b *bytes.Buffer)
| 125 | |
| 126 | // writeNodeText writes the text contained in n and its descendants to b. |
| 127 | func writeNodeText(n *html.Node, b *bytes.Buffer) { |
| 128 | switch n.Type { |
| 129 | case html.TextNode: |
| 130 | b.WriteString(n.Data) |
| 131 | case html.ElementNode: |
| 132 | for c := n.FirstChild; c != nil; c = c.NextSibling { |
| 133 | writeNodeText(c, b) |
| 134 | } |
| 135 | } |
| 136 | } |
| 137 | |
| 138 | // nodeText returns the text contained in n and its descendants. |
| 139 | func nodeText(n *html.Node) string { |