html-cat 0.1.0

HTML5 parser: tokenizer + tree builder producing a Document tree of Element/Text/Comment nodes. No mut, no Rc/Arc, no interior mutability, no panics, exhaustive matches. First sub-crate of a Servo-replacement webview runtime targeting Tauri.
//! HTML5 parser: tokenizer + tree builder producing a [`Document`].
//!
//! # Example
//!
//! ```
//! # fn main() -> Result<(), html_cat::Error> {
//! use html_cat::parse;
//!
//! let doc = parse("<!DOCTYPE html><html><body><p>hi</p></body></html>")?;
//! assert_eq!(doc.root().name(), "html");
//! # Ok(())
//! # }
//! ```

#![cfg_attr(docsrs, feature(doc_auto_cfg))]

pub mod attr;
pub mod entity;
pub mod error;
pub mod node;
pub mod span;
pub mod token;
pub mod tokenizer;
pub mod tree_builder;

pub use error::Error;
pub use node::{Comment, Doctype, Document, Element, Node, Text};

/// Lex and build a [`Document`] from `source`.
///
/// # Errors
///
/// Currently never returns `Err`; the signature reserves an `Error`
/// channel for future strict-mode callers.
pub fn parse(source: &str) -> Result<Document, Error> {
    let tokens = tokenizer::tokenize(source);
    tree_builder::build(tokens)
}