dom

package
v0.2.0 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: 0

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