Documentation
¶
Overview ¶
Package dom provides a Paper-friendly wrapper over golang.org/x/net/html.
Index ¶
- func IsBlockTag(tag string) bool
- type Document
- func (d *Document) HTMLElement() *Node
- func (d *Document) Root() *html.Node
- func (d *Document) StyleSources() (string, []string)
- func (d *Document) StyleText() string
- func (d *Document) ValidateLimits(l htmllimits.Limits) error
- func (d *Document) Walk(fn func(*Node) bool)
- func (d *Document) WalkWithLimits(l htmllimits.Limits, fn func(*Node) bool) error
- type Node
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsBlockTag ¶
IsBlockTag reports whether the given tag name is block-level by the HTML5 default UA stylesheet.
Types ¶
type Document ¶
type Document struct {
// contains filtered or unexported fields
}
Document is the parsed HTML document.
func (*Document) HTMLElement ¶
HTMLElement returns the <html> element wrapped as a *Node, or nil when the document has no html element. Used by the cascade seed so :root and html-level CSS rules apply (Document.Walk starts at body, not the root).
func (*Document) StyleSources ¶
StyleSources returns both the concatenated inline <style> text and the ordered list of <link rel="stylesheet"> href values (in DOM order). External stylesheet content is NOT loaded here; the caller is responsible for resolving each href via a safe resolver.
func (*Document) StyleText ¶
StyleText returns all concatenated <style> block contents. Backward-compatible: returns only inline <style> text, not the contents of <link rel="stylesheet"> sheets. Callers needing both should use StyleSources.
func (*Document) ValidateLimits ¶
func (d *Document) ValidateLimits(l htmllimits.Limits) error
ValidateLimits checks DOM depth and node count without invoking a callback.
func (*Document) Walk ¶
Walk performs a depth-first traversal starting from the document body. The callback returns true to continue traversal, false to stop.
func (*Document) WalkWithLimits ¶
WalkWithLimits performs a depth-first traversal starting from the document body while enforcing DOM resource limits.
type Node ¶
type Node struct {
// contains filtered or unexported fields
}
Node wraps a raw html.Node with Paper-friendly accessors.
func (*Node) InlineStyle ¶
InlineStyle returns the value of the style="" attribute.
func (*Node) RawNode ¶
RawNode returns the underlying golang.org/x/net/html.Node. Callers needing cascadia selector matching can use this directly.
func (*Node) TextContent ¶
TextContent returns the concatenated text of all descendant text nodes. Whitespace is collapsed unless the element is inside <pre>.