use super::ast::{EqNode, SpaceKind};
use super::symbols::FontStyleKind;
pub(super) fn has_source_advances(node: &EqNode) -> bool {
match node.ungrouped() {
EqNode::Text(text) => !text.is_empty() && text.bytes().all(|ch| ch.is_ascii_alphabetic()),
EqNode::Number(text) => !text.is_empty() && text.bytes().all(|ch| ch.is_ascii_digit()),
EqNode::Symbol(text) | EqNode::MathSymbol(text) => {
matches!(
text.as_str(),
"(" | ")" | "'" | "′" | "+" | "=" | "×" | "∙" | "⋅"
)
}
EqNode::Row(items) => items.iter().all(has_source_advances),
EqNode::FontStyle {
style: FontStyleKind::Roman | FontStyleKind::Italic,
body,
}
| EqNode::Color { body, .. } => has_source_advances(body),
EqNode::Space(SpaceKind::Normal | SpaceKind::Thin) | EqNode::Empty => true,
_ => false,
}
}