Skip to main content

rama_http/protocols/html/tokenizer/
mod.rs

1//! A byte-faithful, low-allocation HTML tokenizer.
2//!
3//! The tokenizer scans HTML into a stream of [`StartTag`], [`EndTag`],
4//! [`Text`], [`Comment`] and [`Doctype`] events delivered to a
5//! [`TokenSink`]. It is the substrate for rama's streaming HTML rewriting:
6//! token views borrow the input (no per-token allocation), and every byte
7//! of the input belongs to exactly one token's `raw()` span, so an
8//! unmodified pass re-serializes to byte-identical output.
9//!
10//! Unlike a DOM parser it builds no tree and decodes no character
11//! references — text and attribute values are exposed as raw bytes.
12//!
13//! It is resumable (`write` + `end`) and handles HTML text modes
14//! (`<script>` / `<style>` / `<textarea>` / `<title>` / `<plaintext>` / …)
15//! plus the SVG/MathML foreign-content context needed to distinguish real
16//! CDATA from bogus comments. The identity property holds for all input.
17
18mod context;
19mod machine;
20mod name;
21mod sink;
22mod tag;
23mod token;
24
25#[cfg(test)]
26mod tests;
27
28pub use self::context::ParsingAmbiguityError;
29pub use self::machine::{Tokenizer, tokenize};
30pub use self::name::LocalNameHash;
31pub use self::sink::TokenSink;
32pub use self::tag::HtmlTag;
33pub use self::token::{Attribute, Attributes, Cdata, Comment, Doctype, EndTag, StartTag, Text};