Module rewrite
Available on crate features
html and http only.Expand description
Selector-driven HTML rewriting.
The public entry point is HtmlRewriter (and the rewrite_str
one-shot). Internally, a streaming selector matcher is fed start/end tags
as they are tokenized and reports, at each start tag, which registered
selectors match the element being opened — without building a DOM. It
maintains an open-element stack and, per selector, two bitmasks:
completed— which compound-prefixes are matched ending at this element (a child combinator reads its parent’scompleted);desc_ready— which prefixes are available to descendants (a descendant combinator reads its ancestor’sdesc_ready).
It underpins the selector-driven HtmlRewriter.
Structs§
- Attribute
Name - A validated HTML attribute name.
- Element
- A matched element, for inspection and mutation by a handler.
- Element
Content Handlers - A builder bundling
(selector, closure)pairs — the closure-based escape hatch over theElementContentHandlertrait, for one-off rewrites that don’t need a dedicated state struct. - Html
Rewriter - A streaming, selector-driven HTML rewriter.
Enums§
- Invalid
Attribute Name - Why a string is not a valid
AttributeName.
Traits§
- Element
Content Handler - Handles matched elements during a rewrite.
Functions§
- rewrite_
str - One-shot rewrite of a complete HTML string.
Type Aliases§
- Handler
Result - The result of an element content handler. An error aborts the rewrite.