diff --git a/src/html.rs b/src/html.rs index d4d449b..433f823 100644 --- a/src/html.rs +++ b/src/html.rs @@ -123,6 +123,8 @@ pub fn simplify_html(document: &mut Html, lang: &str) { } remove_ids(document, to_remove.drain(..)); + remove_comments(document); + remove_links(document); remove_attrs(document); @@ -136,6 +138,16 @@ fn remove_ids(document: &mut Html, ids: impl IntoIterator) { } } +fn remove_comments(document: &mut Html) { + let mut to_remove = Vec::new(); + for el in document.root_element().descendants() { + if el.value().is_comment() { + to_remove.push(el.id()); + } + } + remove_ids(document, to_remove.drain(..)); +} + fn remove_attrs(document: &mut Html) { // TODO: See if finding and skipping detached nodes is significantly faster. let mut to_remove = Vec::new();