Skip to main content

collapse_whitespace

Function collapse_whitespace 

Source
pub fn collapse_whitespace(s: &str) -> String
Expand description

Collapses runs of ASCII whitespace into a single space and trims.

Matches the historical strip_tags behaviour in src/plugins/search.rs so the search index stays byte-identical across the port.

ยงExamples

use ssg::util::html_rewriter::collapse_whitespace;

assert_eq!(collapse_whitespace("  hello  world  "), "hello world");
assert_eq!(collapse_whitespace("a\tb\nc"), "a b c");