Documentation
¶
Index ¶
- func Classes(val string) []string
- type Attributes
- func (as *Attributes) AddClass(class string)
- func (as Attributes) Class() string
- func (as *Attributes) DelClass(class string)
- func (as *Attributes) Delete(a *html.Attribute)
- func (as Attributes) Get(key, namespace string) string
- func (as Attributes) ID() string
- func (as Attributes) Len() int
- func (as Attributes) Less(i, j int) bool
- func (as *Attributes) Set(key, namespace, value string) (was string)
- func (as *Attributes) SetClass(val string) (was string)
- func (as *Attributes) SetID(val string) (was string)
- func (as Attributes) Swap(i, j int)
- type Builder
- type Cursor
- func (c *Cursor) Cursor() *Cursor
- func (c *Cursor) Depth() int
- func (c *Cursor) FirstChild() *Node
- func (c *Cursor) LastChild() *Node
- func (c *Cursor) Next() *Node
- func (c *Cursor) NextSibling() *Node
- func (c *Cursor) Node() *Node
- func (c *Cursor) Parent() *Node
- func (c *Cursor) Path() Path
- func (c *Cursor) Prev() *Node
- func (c *Cursor) PrevSibling() *Node
- func (c *Cursor) Seek(m Matcher) bool
- func (c *Cursor) Swap(n *Node) (prev *Node, ok bool)
- type Finder
- type Match
- type Matcher
- func MatchAll(ms ...Matcher) Matcher
- func MatchAny(ms ...Matcher) Matcher
- func MatchAttribute(key, namespace, value string) Matcher
- func MatchChild(m Matcher) Matcher
- func MatchNamespace(namespace string) Matcher
- func MatchTag(tag string) Matcher
- func MatchTagNS(tag, namespace string) Matcher
- func MatchType(t html.NodeType) Matcher
- func Matchers(ms ...Match) []Matcher
- type Node
- func (n *Node) Attr(key string) string
- func (n *Node) AttrNS(key, namespace string) string
- func (n *Node) Attribute(key, namespace string) *html.Attribute
- func (n *Node) Clone() *Node
- func (n *Node) Convert() (*html.Node, error)
- func (n *Node) Cursor() *Cursor
- func (n *Node) Each(m Matcher, f func(n *Node))
- func (n *Node) Find(ms ...Matcher) *Finder
- func (n *Node) HasCycle() bool
- func (n *Node) Match(m *Node) bool
- func (r *Node) PathTo(n *Node) Path
- func (n *Node) Render(w io.Writer) error
- func (n *Node) SetAttr(key, value string) (was string)
- func (n *Node) SetAttrNS(key, namespace, value string) (was string)
- func (n *Node) Swap(n2 *Node) *Node
- type Path
- type Siblings
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Attributes ¶
func (*Attributes) AddClass ¶
func (as *Attributes) AddClass(class string)
func (Attributes) Class ¶
func (as Attributes) Class() string
Class retrieves the value of the "class" attribute
func (*Attributes) DelClass ¶
func (as *Attributes) DelClass(class string)
func (*Attributes) Delete ¶
func (as *Attributes) Delete(a *html.Attribute)
func (Attributes) Get ¶
func (as Attributes) Get(key, namespace string) string
func (Attributes) ID ¶
func (as Attributes) ID() string
func (Attributes) Len ¶
func (as Attributes) Len() int
func (Attributes) Less ¶
func (as Attributes) Less(i, j int) bool
func (*Attributes) Set ¶
func (as *Attributes) Set(key, namespace, value string) (was string)
func (*Attributes) SetClass ¶
func (as *Attributes) SetClass(val string) (was string)
func (*Attributes) SetID ¶
func (as *Attributes) SetID(val string) (was string)
func (Attributes) Swap ¶
func (as Attributes) Swap(i, j int)
type Builder ¶
type Builder interface { // set namespace on current tag Namespace(namespace string) Builder // add attribute Attr(key, value string) Builder // add attribute with namespace AttrNS(key, namespace, value string) Builder // add tag as child, return builder inside child Tag(tag string) Builder // add textnode as child Text(text string) Builder // add multiple child nodes Children(children ...*Node) Builder // return builder inside parent Leave() Builder // retrieve the current node Node() *Node // retrieve the root node Root() *Node }
type Cursor ¶
type Cursor struct {
// contains filtered or unexported fields
}
Cursor points to a node and stores the path to it. It simplifies navigation on nodes.
You must not modify the path to a cursor and the sibling nodes.
func (*Cursor) FirstChild ¶
Parent moves to and retrieves the first child node. If no children exist, the cursor does not move and nil is returned.
func (*Cursor) LastChild ¶
Parent moves to and retrieves the first child node. If no children exist, the cursor does not move and nil is returned.
func (*Cursor) Next ¶
Next moves to and retrieves the depth-first next node. If no next node exists, the cursor does not move and nil is returned.
func (*Cursor) NextSibling ¶
NextSibling moves to and retrieves the next sibling node. If no next sibling exists, the cursor does not move and nil is returned.
func (*Cursor) Parent ¶
Parent moves to and retrieves the parent node. If no parent exists, the cursor does not move and nil is returned.
func (*Cursor) Prev ¶
Prev moves to and retrieves the depth-first previous node. If no previous node exists, the cursor does not move and nil is returned.
func (*Cursor) PrevSibling ¶
PrevSibling moves to and retrieves the previous sibling node. If no previous sibling exists, the cursor does not move and nil is returned.
type Finder ¶
type Finder struct {
// contains filtered or unexported fields
}
type Node ¶
Node is an alternative to golang.org/x/net/html.Node intended for dom mutation. It stores a minimal amount of references that have to be updated on transformations.
func (*Node) Attribute ¶
Attribute retrieves a pointer to the Attribute with the given key and namespace. If none exists, nil is returned.
func (*Node) Convert ¶
Convert a Node to a /x/net/html.Node. If a child node is an ancestor of its own parent, an error will be returned.
type Path ¶
type Path []*Node
Path contains all nodes traversed to get to its last node.
func (Path) Index ¶
Index retrieves the index of the first matching node. It returns -1 if no match is found.
type Siblings ¶
type Siblings []*Node
func (Siblings) Index ¶
Index retrieves the index of the first matching node. It returns -1 if no match is found.
func (Siblings) Splice ¶
Splice copies the siblings and modifies it by deleting del nodes starting at i and inserting ns there.
func (Siblings) SplitBefore ¶
SplitBefore retrieves siblings up to and starting with the first node from which a match is reachable. If no match is found, back is empty.