Documentation
¶
Index ¶
Constants ¶
const MaxNestingDepth = 512
MaxNestingDepth bounds the parser stack of open elements.
Variables ¶
var ErrNestingDepth = errors.New("html: maximum element depth (512) exceeded")
ErrNestingDepth reports HTML nesting beyond the parser's 512-element limit.
Functions ¶
func Parse ¶
Parse returns an independently owned logical tree. Use a retained Parser when the previous tree can be discarded to avoid allocations after warming its storage. Malformed HTML is repaired using the HTML tree construction rules. As before, sources without a leading doctype/html/head/body are parsed as body fragments.
Types ¶
type Parser ¶
type Parser struct {
// contains filtered or unexported fields
}
Parser builds scene nodes directly from UTF-8 source. Its zero value is ready to use. Nodes, attributes, child slices and decoded text are reused on the next Parse or Reset call, which invalidates the previous result. A Parser must not be copied after use or used concurrently.
Unchanged text and names borrow the source string. Decoded strings borrow parser storage; they are immutable until the next Parse or Reset call.
func (*Parser) Parse ¶
Parse replaces the previous result. Once capacity is sufficient, parsing reuses all storage, including entity decoding and malformed-tree repairs.
type Tokenizer ¶
type Tokenizer struct {
// contains filtered or unexported fields
}
Tokenizer scans UTF-8 HTML, borrowing unchanged source text. It skips comments and declarations, recovers malformed input, and handles raw text elements. Returned tokens remain valid for the lifetime of the tokenizer.