Crate ironhtml_parser

Crate ironhtml_parser 

Source
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_std compatible (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.
TreeBuilder
HTML5 tree builder.
ValidationError
A validation error.
Validator
HTML validator.

Enums§

Node
A node in the DOM tree.
NodeType
The type of a DOM node.
Token
A token produced by the tokenizer.

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§

ValidationResult
Validation result containing all errors.