Documentation
¶
Overview ¶
Package markup builds native Onix documents and serializes HTML fragments.
Index ¶
- func EndTag(tag string) string
- func HTML(n *node.Node) string
- func HTMLWithSizeHint(n *node.Node, size int) string
- func StartTag(n *node.Node) string
- type Builder
- func (b *Builder) Document() *node.Node
- func (b *Builder) Element(tag string, attributes ...string) *node.Node
- func (b *Builder) Embed(fragment string)
- func (b *Builder) End()
- func (b *Builder) Open(tag string, attributes ...string) *node.Node
- func (b *Builder) Release()
- func (b *Builder) Reset()
- func (b *Builder) SizeHint() int
- func (b *Builder) String() string
- func (b *Builder) StringWithSubtree(subtree *node.Node) (string, string)
- func (b *Builder) Text(value string)
- func (b *Builder) TextElement(tag, value string, attributes ...string) *node.Node
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func HTMLWithSizeHint ¶
HTMLWithSizeHint reserves space for a known source length before encoding.
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 ¶
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 ¶
Element appends a child. Attributes are alternating names and unescaped values.
func (*Builder) Embed ¶
Embed inserts a previously serialized, trusted HTML fragment at the wire boundary. Native documents should attach nodes directly instead.
func (*Builder) Release ¶
func (b *Builder) Release()
Release invalidates the tree. Oversized views do not reserve arena capacity for subsequent small updates.
func (*Builder) SizeHint ¶
SizeHint estimates the encoded size of authored content, including escaping. Direct mutations of the returned nodes do not update the estimate.
func (*Builder) StringWithSubtree ¶
StringWithSubtree returns the serialized document and the designated subtree's slice of the same string. A missing subtree yields an empty slice.