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

Function ExtractText

htmlcore/text.go:20–25  ·  view source on GitHub ↗

ExtractText recursively extracts all of the text from the children of the given [*html.Node], adding any appropriate inline markup for formatted text. It adds any non-text elements to the given [core.Widget] using [readHTMLNode]. It should not be called on text nodes themselves; for that, you can di

(ctx *Context)

Source from the content-addressed store, hash-verified

18// the given page URL for context when resolving URLs, but it can be
19// omitted if not available.
20func ExtractText(ctx *Context) string {
21 if ctx.Node.FirstChild == nil {
22 return ""
23 }
24 return extractText(ctx, ctx.Node.FirstChild)
25}
26
27func extractText(ctx *Context, n *html.Node) string {
28 str := ""

Callers 4

ExampleHandlerFunction · 0.92
handleElementFunction · 0.85
handleTextFunction · 0.85
handleTextTagFunction · 0.85

Calls 1

extractTextFunction · 0.85

Tested by

no test coverage detected