Manuscript Documentation
v2026.12.0

@std/data/html.ms#

Import each required symbol with import Name from "@std/data/html.ms".

HtmlAttribute Type#

An HTML attribute with its name, namespace and decoded value.

Manuscript
type HtmlAttribute {
    name String
    namespace String
    value String
}

HtmlAttribute.name#

Attribute name after HTML parsing and normalization.

Manuscript
name String

HtmlAttribute.namespace#

Attribute namespace prefix, or empty text for an unqualified attribute.

Manuscript
namespace String

HtmlAttribute.value#

Decoded attribute contents, with character references resolved.

Manuscript
value String

HtmlNode Enum#

A parsed HTML document tree with document, element, text, comment, and doctype nodes.

Manuscript
enum HtmlNode {
    Document(children List[HtmlNode])
    Element(tag String, namespace String, attributes List[HtmlAttribute], children List[HtmlNode])
    Text(text String)
    Comment(text String)
    Doctype(name String, public_id String, system_id String)
}

HtmlNode.Comment#

An HTML comment retained as a node rather than element text.

Manuscript
Comment(text String)

HtmlNode.Doctype#

A document-type declaration retained from the parsed HTML.

Manuscript
Doctype(name String, public_id String, system_id String)

HtmlNode.Document#

Root document node, including any elements implied by HTML tree normalization.

Manuscript
Document(children List[HtmlNode])

HtmlNode.Element#

An element with normalized attributes and its ordered child nodes.

Manuscript
Element(tag String, namespace String, attributes List[HtmlAttribute], children List[HtmlNode])

HtmlNode.Text#

Text node contents after HTML entity decoding and tree normalization.

Manuscript
Text(text String)

HtmlNode.Comment.text#

Comment contents without the opening and closing comment delimiters.

Manuscript
text String

HtmlNode.Doctype.name#

Doctype name as normalized by the parser.

Manuscript
name String

HtmlNode.Doctype.public_id#

Public identifier, or empty text when no public identifier is present.

Manuscript
public_id String

HtmlNode.Doctype.system_id#

System identifier, or empty text when no system identifier is present.

Manuscript
system_id String

HtmlNode.Document.children#

Direct child nodes in normalized document order.

Manuscript
children List[HtmlNode]

HtmlNode.Element.attributes#

Attributes in parser order, with decoded values and namespace information.

Manuscript
attributes List[HtmlAttribute]

HtmlNode.Element.children#

Direct child nodes in normalized tree order.

Manuscript
children List[HtmlNode]

HtmlNode.Element.namespace#

Element namespace, svg or math, or empty text for ordinary HTML.

Manuscript
namespace String

HtmlNode.Element.tag#

Local element tag name produced by the HTML parser.

Manuscript
tag String

HtmlNode.Text.text#

Unicode text belonging to this node, without surrounding markup.

Manuscript
text String

HtmlOptions Type#

Limits for parse on input bytes, tree depth and node count. A field set to null adds no limit. The defaults are a depth of 10,000 and 1,000,000 nodes, with no limit on input bytes. A negative limit returns EINVAL, and input that exceeds a limit returns EOVERFLOW.

Manuscript
type HtmlOptions {
    max_bytes Int? = null
    max_depth Int? = 10000
    max_nodes Int? = 1000000
}

HtmlOptions.max_bytes#

Maximum UTF-8 input bytes before parsing; null adds no input-size budget.

Manuscript
max_bytes Int? = null

HtmlOptions.max_depth#

Maximum normalized node depth; the document is depth zero and direct children depth one.

Manuscript
max_depth Int? = 10000

HtmlOptions.max_nodes#

Maximum returned nodes, including document/text/comment/doctype and implied element nodes.

Manuscript
max_nodes Int? = 1000000

escape Function#

Escapes text for insertion into an HTML text or quoted attribute context.

Manuscript
fn escape(text String) String { ... }

parse Function#

Parses HTML into a normalized tree and applies the limits in options. The result is the Document node.

Manuscript
fn parse(text String, options HtmlOptions = HtmlOptions()) Result[HtmlNode, Error] { ... }

unescape Function#

Decodes HTML5 named and numeric character references in text context, once. A recognized reference may omit its semicolon; unrecognized text stays literal. Invalid numeric references become U+FFFD. It does not parse markup or normalize text.

Manuscript
fn unescape(text String) String { ... }