Markup

Markup :: # (opaque)

Shared markup identities, source trees, contexts and templates.

validate_tree : Parsed, Props -> Try(Parsed, [InvalidMarkup(Error)])

Validate all names, attribute values and child models in a supplied tree. Unavailable template values can only be skipped by internal slot parsing.

Context

Markup.Context :: # (opaque)
from_parent : Props -> Try(Context, [InvalidPlacement(Diagnostic(Problem))])
child : Context, ChildProps -> Try(Context, [InvalidPlacement(Diagnostic(Problem))])
text : Context, Str -> Try({}, [InvalidPlacement(Diagnostic(Problem))])

Validate decoded text against the parent's content model.

Props

:= { parent : Name, attributes : List(Attribute) ?? [], syntax : Syntax ?? HtmlSyntax, scripting : [Enabled, Disabled] ?? Enabled }

Validate a parent identity and seed its authoring context.

ChildProps

:= { name : Name, attributes : List(Attribute) ?? [] }

Validate a child without changing the reusable parent context.

Template

Markup.Template :: # (opaque)

Plan

Markup.Template.Plan :: # (opaque)

A template's immutable structure and its original static segments.

metadata : Plan -> PlanMetadata

Static source regions and slots established by checked parsing.

bind : Plan, Iter(a) -> Try(Bound(a), [InvalidMarkup(Error)])

Bind an iterator, checking the expected arity.

Bound

Markup.Template.Bound(a) :: # (opaque)

Values retain their original type, including closures and reactive values.

metadata : Bound(a) -> { plan : Plan, values : List(a) }

Inspect validated bindings without enabling unchecked assembly.

binding : Bound(a), U64 -> Try(a, [Missing])

Look up one bound value without interpreting it as markup.

ContextProps

:= { parent : Name, attributes : List(Attribute) ?? [], syntax : Syntax ?? HtmlSyntax, scripting : [Enabled, Disabled] ?? Enabled }

Validate a parent identity and seed its authoring context.

ContextChildProps

:= { name : Name, attributes : List(Attribute) ?? [] }

Validate a child without changing the reusable parent context.

Source

:= { bytes : List(U8), tokens : List(Token) }

Lossless bytes and a partition into lexical regions.

is_eq : _

Compare the retained source and lexical ranges.

to_hash : _

Hash the retained source and lexical ranges.

from_bytes : List(U8) -> Source

Retain arbitrary bytes, including malformed UTF-8 and incomplete tags.

from_tokens : List(U8), List(Token) -> Source

Retain token regions produced by a syntax-specific parser. Regions must partition the supplied bytes; partition_valid checks this invariant.

partition_valid : Source -> Bool

Whether token ranges cover every byte once, in order, without empty regions. An empty input has an empty token list.

from_str : Str -> Source

Retain UTF-8 source without normalization.

slice : Source, Span -> List(U8)

The exact bytes of a source token.

position : Source, U64 -> { line : U64, column : U64 }

Locate a byte offset using the common one-based UTF-8 position convention.

Props

:= { syntax : Syntax ?? XmlSyntax, exact_structure : Bool ?? False, strict_foreign_spelling : Bool ?? False, allow_unknown_elements : Bool ?? False, allow_unknown_attributes : Bool ?? False, check_values : Bool ?? True, max_source_bytes : U64 ?? 16_777_216, max_depth : U64 ?? 1024, max_elements : U64 ?? 4_194_304, max_nodes : U64 ?? 4_194_304, max_slots : U64 ?? 65_536, max_attributes : U64 ?? 1024, recovery : [Strict, Browser] ?? Strict, max_diagnostics : U64 ?? 1024, max_work_per_byte : U64 ?? 256 }

Configurable validation and resource limits, strict by default. exact_structure rejects repaired HTML nesting before derived projection. strict_foreign_spelling requires authored SVG/MathML names to match their canonical DOM spelling in HTML syntax, including closing tags. XML work counts deterministic source-byte traversals and reader events; it is a progress ceiling rather than a count of machine instructions.

InitialNewlineState

Markup.InitialNewlineState :: # (opaque)

One-token HTML initial-line-feed state, created from an element's text behavior.

from_behavior : [DropInitialLf, PreserveInitialLf] -> InitialNewlineState
step : InitialNewlineState, Token -> { state : InitialNewlineState, token : Token, action : [Skipped, Preserved] }

Empty character bindings preserve pending state; any other token consumes it.

Token : [Characters(Str), Comment, Other]

Name

:= { namespace : Namespace, local : Str, prefix : [Prefix(Str), Unprefixed] }

Explicit expanded identity shared by XML and markup; no vocabulary validity is implied.

from_qualified : QualifiedProps -> Try(Name, [InvalidDomName(Diagnostic(Problem))])

Validate a computed DOM spelling and retain its explicit namespace identity.

qualified : Name -> Str

Format the explicitly supplied prefix; a colon in local remains literal.

initial_newline : Name -> InitialNewlineState

Seed the serializer's first-token line-feed rule from this name.

Problem : [InvalidCharacter({ spelling : Str, context : Context }), InvalidNamespace({ namespace : Namespace, spelling : Str })]

TextProps

:= { scripting : [Enabled, Disabled] ?? Enabled }

NameProps

:= { namespace : Namespace, spelling : Str, context : Context }

NameTextProps

:= { scripting : [Enabled, Disabled] ?? Enabled }

Tree

:= { nodes : List(Node), roots : List(U64) }

Indexed nodes with document/fragment roots in authored order.

single_root : Tree -> Try(U64, [RootCount(U64)])

The only element root, ignoring comments and processing instructions.

text : Tree, U64 -> Str

All descendant character data in document order, without recursive calls.