Expand description
§ironhtml-parser
HTML5 parser following the WHATWG HTML Living Standard.
This crate provides a parser that converts HTML strings into a DOM tree, handling malformed HTML gracefully like browsers do.
§Features
- Parse HTML5 documents and fragments
- Handles malformed HTML gracefully
no_stdcompatible (with alloc)- Produces a DOM tree that can be traversed and validated
§Example
use ironhtml_parser::{parse, parse_fragment, Node};
// Parse a complete document
let doc = parse("<!DOCTYPE html><html><body><p>Hello</p></body></html>");
assert!(doc.doctype.is_some());
// Parse a fragment
let nodes = parse_fragment("<div class=\"container\"><span>Text</span></div>");
assert_eq!(nodes.len(), 1);§Specification Reference
Structs§
- Attribute
- An attribute on an element.
- Document
- An HTML document.
- Element
- An HTML element.
- Text
- A text node.
- Tokenizer
- HTML5 tokenizer.
- Tree
Builder - HTML5 tree builder.
- Validation
Error - A validation error.
- Validator
- HTML validator.
Enums§
Functions§
- parse
- Parse an HTML document string into a Document.
- parse_
fragment - Parse an HTML fragment string into a list of nodes.
- validate
- Validate an HTML document and return any errors.
- validate_
fragment - Validate an HTML fragment and return any errors.
Type Aliases§
- Validation
Result - Validation result containing all errors.