parse

package
v0.1.10 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 23, 2026 License: MIT Imports: 8 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNestingDepth = errors.New("html: maximum element depth (512) exceeded")

ErrNestingDepth reports HTML nesting beyond the parser's 512-element limit.

Functions

func Parse

func Parse(input string) (*uinode.Node, error)

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.

func ParseTree

func ParseTree(input string) (*uinode.Node, error)

ParseTree constructs an independently owned tree for callers that initialize document order and form state as part of their own document preparation.

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

func (p *Parser) Parse(input string) (*uinode.Node, error)

Parse replaces the previous result. Once capacity is sufficient, parsing reuses all storage, including entity decoding and malformed-tree repairs.

func (*Parser) Reset

func (p *Parser) Reset()

Reset invalidates the previous tree and releases source references while retaining reusable capacity. Assign Parser{} to release the retained capacity as well.

type Token

type Token struct {
	uinode.AttributeSet
	Data string
	Type TokenType
}

type TokenType

type TokenType int
const (
	TokenError TokenType = iota
	TokenEOF
	TokenText
	TokenStartTag
	TokenEndTag
	TokenSelfClosingTag
)

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.

func NewTokenizer

func NewTokenizer(input string) *Tokenizer

func (*Tokenizer) Next

func (t *Tokenizer) Next() (Token, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL