use scraper::Html;
pub fn plain_text(html: &str) -> String {
Html::parse_fragment(html)
.root_element()
.text()
.flat_map(str::split_whitespace)
.collect::>()
.join(" ")
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn strips_tags_and_collapses_whitespace() {
assert_eq!(
plain_text("Hello big
\nworld & co
"),
"Hello big world & co"
);
}
}