(ctx *Context, n *html.Node)
| 25 | } |
| 26 | |
| 27 | func extractText(ctx *Context, n *html.Node) string { |
| 28 | str := "" |
| 29 | if n.Type == html.TextNode { |
| 30 | str += n.Data |
| 31 | } |
| 32 | it := isText(n) |
| 33 | if !it { |
| 34 | readHTMLNode(ctx, ctx.Parent(), n) |
| 35 | } |
| 36 | if it && n.FirstChild != nil { |
| 37 | start, end := nodeString(n) |
| 38 | str = start + extractText(ctx, n.FirstChild) + end |
| 39 | } |
| 40 | if n.NextSibling != nil { |
| 41 | str += extractText(ctx, n.NextSibling) |
| 42 | } |
| 43 | return str |
| 44 | } |
| 45 | |
| 46 | // nodeString returns the given node as starting and ending strings in the format: |
| 47 | // |
no test coverage detected