Expand description
HTML toolkit based on html5ever and cinereus.
hotmeal provides:
- Arena-based DOM: Efficient arena-allocated tree with zero-copy parsing
- Parsing: Browser-compatible HTML5 parsing via html5ever with full error recovery
- Serialization: HTML5-correct serialization with proper escaping
- Diffing: DOM patch generation for live-reloading
§Example
use hotmeal::{parse, NodeKind, StrTendril};
let input = StrTendril::from("<!DOCTYPE html><html><body><p>Hello!</p></body></html>");
let doc = parse(&input);
assert_eq!(doc.doctype.as_ref().map(|s| s.as_ref()), Some("html"));
if let Some(body_id) = doc.body() {
for child_id in body_id.children(&doc.arena) {
let node = doc.get(child_id);
if let NodeKind::Element(elem) = &node.kind {
println!("Found {} element", elem.tag);
}
}
}
// Serialize back to HTML
let html = doc.to_html();Macros§
- debug
- Emit a debug-level log message (no-op version).
- local_
name - Takes a local name as a string and returns its key in the string cache.
- namespace_
url - Takes a namespace url string and returns its key in a string cache.
- ns
- Maps the input of
namespace_prefix!to the output ofnamespace_url!. - trace
- Emit a trace-level log message (no-op version).
Structs§
- Attr
Pair - An attribute name-value pair
- Document
- Arena-based DOM document.
- Element
Data - Element data (tag + attributes)
- Html
Props - HTML element properties (attributes only). Text content is stored separately in NodeData::text.
- Html
Tree Types - Tree types marker for HTML DOM.
- Node
Data - What goes in each arena slot
- NodeId
- A node identifier within a particular
Arena. - Node
Path - A path to a node in the DOM tree.
- NodeRef
- Reference to a node via a path.
- Prop
Change - A property in the final state within an UpdateProps operation. The vec position determines the final ordering.
- Qual
Name - A fully qualified name (with a namespace), used to depict names of tags and attributes.
Enums§
- Diff
Error - Errors that can occur during diffing or patch application.
- Html
Node Kind - Node kind in the HTML tree.
- Insert
Content - Content that can be inserted as part of a new subtree.
- Namespace
- XML namespace
- Node
Kind - Node types
- Patch
- Operations to transform the DOM.
- PropKey
- Property key - either text content or an attribute
- Stem
- Compact string type used for text content, comments, and attribute values.
Functions§
- diff
- Diff two arena documents and return DOM patches.
- diff_
html - Diff two HTML tendrils and return DOM patches.
- parse
- Parse HTML from a StrTendril with zero-copy borrowing.
- parse_
body_ fragment - Parse HTML as a body fragment (like
body.innerHTML = html).
Type Aliases§
- Local
Name - StrTendril
Tendrilfor storing native Rust strings.