use quick_xml::name::QName;
pub(super) fn qname_eq(name: QName<'_>, expected: &[u8]) -> bool {
let n = name.as_ref();
n == expected || n.rsplit(|b| *b == b':').next() == Some(expected)
}
pub(super) fn push_text(target: &mut String, piece: &str) {
let trimmed = piece.trim_matches([' ', '\n', '\r'].as_slice());
if trimmed.is_empty() {
return;
}
if !target.is_empty() && !target.ends_with('\t') && !trimmed.starts_with('\t') {
target.push(' ');
}
target.push_str(trimmed);
}
#[allow(dead_code)]
pub(super) fn push_event_text(target: &mut String, piece: &str, is_entity: bool) {
if is_entity {
target.push_str(piece);
} else {
push_text(target, piece);
}
}
pub(super) fn collapse_whitespace(text: &str) -> String {
let mut out = String::with_capacity(text.len());
let mut in_space = false;
for ch in text.chars() {
if ch.is_whitespace() {
if !in_space {
out.push(' ');
in_space = true;
}
} else {
out.push(ch);
in_space = false;
}
}
out.trim().to_string()
}