export text and firsttext functions

This commit is contained in:
gutmet 2019-01-13 19:01:48 +01:00
parent 148b3f261d
commit bb2d3e26ea

View File

@ -79,7 +79,7 @@ func (n *HtmlNode) GetElementsByClass(class string) []*HtmlNode {
}
}
func (n *HtmlNode) text() string {
func (n *HtmlNode) Text() string {
if n == nil {
return ""
}
@ -98,7 +98,7 @@ func (n *HtmlNode) text() string {
}
}
func (n *HtmlNode) firstText() string {
func (n *HtmlNode) FirstText() string {
text := n.Find(func(n *HtmlNode) bool { return n.Type == html.TextNode })
return strings.TrimSpace(text.Data)
}