markup

package
v0.1.11 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2026 License: MIT Imports: 3 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

Overview

Package markup builds native Onix documents and serializes HTML fragments.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EndTag

func EndTag(tag string) string

EndTag closes a non-void element for streaming HTML renderer callbacks.

func HTML

func HTML(n *node.Node) string

HTML serializes a native document or subtree for transport.

func HTMLWithSizeHint

func HTMLWithSizeHint(n *node.Node, size int) string

HTMLWithSizeHint reserves space for a known source length before encoding.

func StartTag

func StartTag(n *node.Node) string

StartTag serializes an opening element for streaming HTML renderer callbacks.

Types

type Builder

type Builder struct {
	// contains filtered or unexported fields
}

Builder constructs an ordered tree in a reusable arena. Its zero value is ready to use. Reset invalidates its nodes, but previously serialized strings stay valid.

func Acquire

func Acquire() *Builder

Acquire returns a reusable builder for producers that serialize their tree.

func (*Builder) Document

func (b *Builder) Document() *node.Node

Document returns the native tree. A builder with embedded wire fragments can only be serialized, since those fragments have no corresponding nodes.

func (*Builder) Element

func (b *Builder) Element(tag string, attributes ...string) *node.Node

Element appends a child. Attributes are alternating names and unescaped values.

func (*Builder) Embed

func (b *Builder) Embed(fragment string)

Embed inserts a previously serialized, trusted HTML fragment at the wire boundary. Native documents should attach nodes directly instead.

func (*Builder) End

func (b *Builder) End()

End returns to the enclosing element.

func (*Builder) Open

func (b *Builder) Open(tag string, attributes ...string) *node.Node

Open makes the new element the parent of subsequent children.

func (*Builder) Release

func (b *Builder) Release()

Release invalidates the tree. Oversized views do not reserve arena capacity for subsequent small updates.

func (*Builder) Reset

func (b *Builder) Reset()

func (*Builder) SizeHint

func (b *Builder) SizeHint() int

SizeHint estimates the encoded size of authored content, including escaping. Direct mutations of the returned nodes do not update the estimate.

func (*Builder) String

func (b *Builder) String() string

func (*Builder) StringWithSubtree

func (b *Builder) StringWithSubtree(subtree *node.Node) (string, string)

StringWithSubtree returns the serialized document and the designated subtree's slice of the same string. A missing subtree yields an empty slice.

func (*Builder) Text

func (b *Builder) Text(value string)

func (*Builder) TextElement

func (b *Builder) TextElement(tag, value string, attributes ...string) *node.Node

Jump to

Keyboard shortcuts

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