Expand description
LOL HTML is a Low Output Latency streaming HTML rewriter/parser with CSS-selector based API.
It is designed to modify HTML on the fly with minimal buffering. It can quickly handle very large documents, and operate in environments with limited memory resources.
The crate serves as a back-end for the HTML rewriting functionality of Cloudflare Workers, but can be used as a standalone library with the convenient API for a wide variety of HTML rewriting/analysis tasks.
The crate provides two main API entry points:
HtmlRewriter
- a streaming HTML rewriter;rewrite_str
- one-off HTML string rewriting function.
Modules§
- errors
- The errors that can be produced by the crate’s API.
- html_
content - HTML content descriptors that can be produced and modified by a rewriter.
- send
- This module contains type aliases that make the
HtmlRewriter
safe to move between threads (have theSend
bound).
Macros§
- comments
- A convenience macro to construct a rewriting handler for HTML comments in the inner content of an element that can be matched by the specified CSS selector.
- doc_
comments - A convenience macro to construct a rewriting handler for all HTML comments in the HTML document.
- doc_
text - A convenience macro to construct a rewriting handler for all text chunks in the HTML document. Beware: this is tricky to use.
- doctype
- A convenience macro to construct a handler for document type declarations in the HTML document.
- element
- A convenience macro to construct a rewriting handler for elements that can be matched by the specified CSS selector.
- end
- A convenience macro to construct a rewriting handler for the end of the document.
- streaming
- A convenience macro to construct a
StreamingHandler
from a closure. - text
- A convenience macro to construct a rewriting handler for fragments of text in the inner content of an element that can be matched by the specified CSS selector. Beware: this is tricky to use.
Structs§
- Ascii
Compatible Encoding - This is an encoding known to be ASCII-compatible.
- Document
Content Handlers - Specifies document-level content handlers.
- Element
Content Handlers - Specifies element content handlers associated with a selector.
- Html
Rewriter - A streaming HTML rewriter.
- Local
Handler Types - Handler type for non-
Send
ableHtmlRewriter
s. - Memory
Settings - Specifies the memory settings for
HtmlRewriter
. - Rewrite
StrSettings - Specifies settings for the
rewrite_str
function. - Selector
- Parsed CSS selector.
- Settings
- Specifies settings for
HtmlRewriter
.
Traits§
- Handler
Types - Trait used to parameterize the type of handlers used in the rewriter.
- Output
Sink - Defines an interface for the
HtmlRewriter
’s output.
Functions§
- rewrite_
str - Rewrites given
html
string with the providedsettings
.
Type Aliases§
- Comment
Handler - Boxed closure for handling HTML comments.
- Doctype
Handler - Boxed closure for handling the document type declaration.
- Element
Handler - Boxed closure for handling elements matched by a selector.
- EndHandler
- Boxed closure for handling the document end. This is called after the last chunk is processed.
- EndTag
Handler - Boxed closure for handling end tags.
- Handler
Result - The result of a handler.
- Text
Handler - Boxed closure for handling text chunks present the HTML.