Documentation ¶
Overview ¶
Copyright 2022 Hal Canary Use of this program is governed by the file LICENSE.
This is a lightweight wrapper around x/net/html, providing some extra functionality.
Index ¶
- Constants
- func ExtractText(root *Node) string
- func GetAttribute(node *Node, key string) string
- func RenderHTML(root *Node, w io.Writer) error
- func RenderHTMLExperimental(root *Node, w io.Writer) error
- func RenderXHTMLDoc(root *Node, w io.Writer) error
- func TextBytes(root *Node) int
- type Attr
- type Attribute
- type Node
- func AddAttribute(node *Node, k, v string) *Node
- func Append(node *Node, children ...*Node) *Node
- func Comment(data string) *Node
- func Elem(tag string, children ...*Node) *Node
- func Element(tag string, attributes Attr, children ...*Node) *Node
- func FindNodeByAttribute(node *Node, key, value string) *Node
- func FindNodeById(node *Node, id string) *Node
- func FindNodeByTag(node *Node, tag string) *Node
- func FindNodeByTagAndAttrib(root *Node, tag, key, value string) *Node
- func FindNodeByTagAndAttribRe(root *Node, tag, key string, value *regexp.Regexp) *Node
- func FindNodesByTagAndAttrib(root *Node, tag, key, value string) []*Node
- func FindNodesByTagAndAttribRe(root *Node, tag, key string, value *regexp.Regexp) []*Node
- func Parse(source io.Reader) (*Node, error)
- func ParseFragment(source io.Reader, context *Node) ([]*Node, error)
- func RawHtml(data string) *Node
- func Remove(node *Node) *Node
- func Text(data string) *Node
Constants ¶
const ( ElementNode = html.ElementNode TextNode = html.TextNode )
Variables ¶
This section is empty.
Functions ¶
func ExtractText ¶
Extract and combine all Text Nodes under given node.
func GetAttribute ¶
Find the matching attributes, ignoring namespace.
func RenderHTMLExperimental ¶
Generates HTML5 doc.
Types ¶
type Node ¶
func AddAttribute ¶
Add an attribute to an element node, returning the node.
func FindNodeByAttribute ¶
Return the first matching node with key attribude set to value.
func FindNodeById ¶
Return the first matching node with `id` attribude set to id.
func FindNodeByTag ¶
Return the first matching node
func FindNodeByTagAndAttrib ¶
Return the first matching node. If tag is "", match key="value". If key is "", match on tag.
func FindNodeByTagAndAttribRe ¶ added in v1.1.0
Return the first matching node. If tag is "", match key="value". If key is "", match on tag.
func FindNodesByTagAndAttrib ¶
Return all matching nodes. If tag is "", match key="value". If key is "", match on tag.
func FindNodesByTagAndAttribRe ¶ added in v1.2.0
func ParseFragment ¶ added in v0.1.5
Wrapper for html.ParseFragment.