pub(crate) fn is_line_break(character: char) -> bool {
matches!(
character,
'\n' | '\r' | '\u{0B}' | '\u{0C}' | '\u{85}' | '\u{2028}' | '\u{2029}'
)
}
pub(crate) fn flatten_line_breaks(text: &str) -> String {
let mut line = String::with_capacity(text.len());
let mut chars = text.chars().peekable();
while let Some(character) = chars.next() {
if !is_line_break(character) {
line.push(character);
continue;
}
line.push(' ');
if character == '\r' && chars.peek() == Some(&'\n') {
chars.next();
}
}
line
}