macro_rules! doc_text {
($handler:expr) => { ... };
}Expand description
A convenience macro to construct a rewriting handler for all text chunks in the HTML document. Beware: this is tricky to use.
The text chunks may split the text nodes into smaller fragments. See TextChunk for more info.
ยงExample
use lol_html::{rewrite_str, doc_text, RewriteStrSettings};
use lol_html::html_content::ContentType;
let html = rewrite_str(
r#"Hello<span>Hello</span>Hello"#,
RewriteStrSettings {
document_content_handlers: vec![
doc_text!(|t| {
if t.last_in_text_node() {
t.after(" world", ContentType::Text);
}
Ok(())
})
],
..RewriteStrSettings::new()
}
).unwrap();
assert_eq!(html, r#"Hello world<span>Hello world</span>Hello world"#);