Skip to main content

Crate hotmeal

Crate hotmeal 

Source
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 of namespace_url!.
trace
Emit a trace-level log message (no-op version).

Structs§

AttrPair
An attribute name-value pair
Document
Arena-based DOM document.
ElementData
Element data (tag + attributes)
HtmlProps
HTML element properties (attributes only). Text content is stored separately in NodeData::text.
HtmlTreeTypes
Tree types marker for HTML DOM.
NodeData
What goes in each arena slot
NodeId
A node identifier within a particular Arena.
NodePath
A path to a node in the DOM tree.
NodeRef
Reference to a node via a path.
PropChange
A property in the final state within an UpdateProps operation. The vec position determines the final ordering.
QualName
A fully qualified name (with a namespace), used to depict names of tags and attributes.

Enums§

DiffError
Errors that can occur during diffing or patch application.
HtmlNodeKind
Node kind in the HTML tree.
InsertContent
Content that can be inserted as part of a new subtree.
Namespace
XML namespace
NodeKind
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§

LocalName
StrTendril
Tendril for storing native Rust strings.