MCPcopy Create free account
hub / github.com/cogentcore/core / extractText

Function extractText

htmlcore/text.go:27–44  ·  view source on GitHub ↗
(ctx *Context, n *html.Node)

Source from the content-addressed store, hash-verified

25}
26
27func 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//

Callers 1

ExtractTextFunction · 0.85

Calls 4

isTextFunction · 0.85
readHTMLNodeFunction · 0.85
nodeStringFunction · 0.85
ParentMethod · 0.45

Tested by

no test coverage detected