Expand description
Parses a pragmatic HTML subset into a custom Node tree; this is not an HTML5 parser.
Tags are never implicitly closed. When input ends with open tags, remaining stack entries are
returned as top-level nodes. Whitespace-only ordinary text nodes are omitted; raw-text element
bodies are preserved.
Supported element names map to their NodeType variants; all others become NodeType::Unknown.
Closing-tag names are not matched: any closing tag closes the most recently opened node. A
single top-level node is returned directly; zero or multiple top-level nodes are wrapped in a
synthetic Node whose tag_name is None.
safe_parse_html returns a structured error for malformed input.
Enums§
- Malformed
Attribute Error - Errors reported for malformed HTML attributes.
- Malformed
TagError - Errors reported for malformed HTML tags.
- ParseHTML
Error - Errors that can occur while parsing HTML.
Functions§
- safe_
parse_ html - Consumes an owned HTML string and returns a
Nodetree.