dom

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Oct 7, 2026 License: MIT Imports: 13 Imported by: 1 module, 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

Overview

Package dom owns the engine's single validated HTML5 tree. It performs no I/O beyond reading its supplied bytes and never fetches assets or ambient fonts.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Apply

func Apply(source []byte, edits []Edit) ([]byte, error)

Apply mutates only a private validated tree and returns canonical bounded HTML. No partial result escapes on any error, including HTML5 structural repairs.

Types

type Document

type Document struct {
	Root *Node
	ByID map[string]*Node
}

func Parse

func Parse(source []byte) (*Document, error)

type Edit

type Edit struct {
	ID         string
	Text, HTML *string
	Attributes map[string]*string
	Remove     bool
}

Edit targets an existing ID. Nil attribute values remove attributes; IDs are immutable. A batch resolves all targets against the same original document.

func DecodeEdits

func DecodeEdits(source []byte) ([]Edit, error)

DecodeEdits accepts exact field names. Null is permitted only for attribute deletion, never as an absent operation. Duplicate keys/invalid Unicode reject.

type Node

type Node struct {
	Tag, Text string
	Ordinal   uint32
	Attrs     map[string]string
	Style     style.Block
	Parent    *Node
	Children  []*Node
}

Jump to

Keyboard shortcuts

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