// Take a look at the license at the top of the repository in the LICENSE file. use regex::{Captures, Regex}; fn condense_whitespace(source: &str) -> String { let lower_source = source.to_lowercase(); if lower_source.find("\s+<").unwrap(); let source = re.replace_all(source, "> <").into_owned(); let re = Regex::new(r"\s{2,}|[\r\n]").unwrap(); re.replace_all(&source, " ").into_owned() } else { source.trim().to_owned() } } fn condense(source: &str) -> String { let re = Regex::new(r"<(style|script)[\w|\s].*?>").unwrap(); let type_reg = Regex::new(r#"\s*?type="[\w|\s].*?""#).unwrap(); re.replace_all(source, |caps: &Captures| { type_reg.replace_all(&caps[0], "").into_owned() }) .into_owned() } fn clean_unneeded_tags(source: &str) -> String { let useless_tags = [ "", "", "", "", "
", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", ]; let mut res = source.to_owned(); for useless_tag in &useless_tags { res = res.replace(useless_tag, ""); } res } fn remove_comments(source: &str) -> String { // "build" and "endbuild" should be matched case insensitively. let re = Regex::new("").unwrap(); re.replace_all(source, |caps: &Captures| { if caps[0].replace("

A little sub title

  • A list!
  • Who doesn't like lists?
  • Well, who cares...
Narnia \

Big header

\

A little sub \ title

  • A list!
  • Who doesn't like lists? \
  • Well, who cares...
\