Compare commits
2 commits
8b4b2ec3cd
...
f84ae8d1fd
Author | SHA1 | Date | |
---|---|---|---|
ptrcnull | f84ae8d1fd | ||
ptrcnull | 5ab9ae9ca3 |
14
html.go
14
html.go
|
@ -28,6 +28,16 @@ func ParseNode(r io.Reader) (*Node, error) {
|
|||
return &Node{n[0]}, nil
|
||||
}
|
||||
|
||||
func NewTextNode(text string) *Node {
|
||||
return &Node{
|
||||
Node: &html.Node{
|
||||
Type: html.TextNode,
|
||||
DataAtom: 0x0,
|
||||
Data: text,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func (n *Node) QuerySelector(selector string) *Node {
|
||||
if strings.HasPrefix(selector, "#") {
|
||||
return n.GetElementById(selector[1:])
|
||||
|
@ -175,6 +185,10 @@ func (n *Node) Text() string {
|
|||
return res
|
||||
}
|
||||
|
||||
func (n *Node) TrimmedText() string {
|
||||
return strings.Trim(n.Text(), " \n\t")
|
||||
}
|
||||
|
||||
func (n *Node) Render() (string, error) {
|
||||
w := bytes.NewBuffer([]byte{})
|
||||
err := html.Render(w, n.Node)
|
||||
|
|
Loading…
Reference in a new issue