lol_html

Macro doc_comments

source
macro_rules! doc_comments {
    ($handler:expr) => { ... };
}
Expand description

A convenience macro to construct a rewriting handler for all HTML comments in the HTML document.

ยงExample

use lol_html::{rewrite_str, doc_comments, RewriteStrSettings};
use lol_html::html_content::ContentType;

let html = rewrite_str(
    r#"<!-- 42 --><span><!-- 42 --></span><!-- 42 -->"#,
    RewriteStrSettings {
        document_content_handlers: vec![
            doc_comments!(|c| {
                c.set_text("Hello!").unwrap();

                Ok(())
            })
        ],
        ..RewriteStrSettings::new()
    }
).unwrap();

assert_eq!(html, r#"<!--Hello!--><span><!--Hello!--></span><!--Hello!-->"#);