tree

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package tree is the internal, validated element model the layout pipeline walks. It is built from a parsed contract.Tree: structural props (the pagination- and identity-relevant ones) are parsed into typed fields, while style values are kept raw for the stylesheet subsystem, exactly as react-pdf leaves styles uninterpreted until layout.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Path

func Path(n *Node) string

Path returns a human-readable location for a node, e.g. "Document > Page[0] > View[2] > Text[1]", used in validation and render errors.

func Validate

func Validate(root *Node) error

Validate checks the structural rules react-pdf enforces on the element tree. It returns all violations joined into one error, each carrying an element path; a valid tree returns nil.

Types

type Node

type Node struct {
	Type  string
	Value string // TEXT_INSTANCE text content

	// Parsed structural props (react-pdf pagination and identity semantics).
	Wrap             *bool // nil = unset; the type default is applied at layout
	Fixed            bool
	Break            bool
	MinPresenceAhead float64
	Debug            bool
	ID               string
	Render           *contract.CallbackRef // render prop, when it is a function

	Style any            // raw style value (object or array); parsed by stylesheet
	Props map[string]any // all props verbatim

	Parent   *Node
	Children []*Node
}

Node is one element of the internal tree.

func (*Node) Clone

func (n *Node) Clone() *Node

Clone deep-copies the subtree rooted at n, rewiring Parent pointers. Props maps are copied shallowly (values are treated as immutable after Build).

type Tree

type Tree struct {
	Root                *Node
	Fonts               []contract.FontRegistration
	EmojiSource         *contract.EmojiSource
	HyphenationCallback *contract.CallbackRef
	Warnings            []string
}

Tree is a built, validated document tree plus the document-level assets the render pipeline needs.

func Build

func Build(ct *contract.Tree) (*Tree, error)

Build constructs the internal tree from a parsed contract and validates its structure. On a structural error it returns the error (with element paths) and a nil tree.

Jump to

Keyboard shortcuts

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