use crate::ast::{Measurement, ParseNode, StyleLevel};
use crate::symbol_registry::unicode_symbol;
pub fn resolve_symbol(text: &str) -> String {
unicode_symbol(text).unwrap_or_else(|| text.to_string())
}
pub fn is_null_delimiter(text: &str) -> bool {
text == "."
}
pub fn command_name(label: &str) -> String {
label.strip_prefix('\\').unwrap_or(label).to_string()
}
pub fn katex_size_multiplier(size: usize) -> f64 {
const SIZES: [f64; 11] = [0.5, 0.6, 0.7, 0.8, 0.9, 1.0, 1.2, 1.44, 1.728, 2.074, 2.488];
size.checked_sub(1)
.and_then(|index| SIZES.get(index))
.copied()
.unwrap_or(1.0)
}
pub fn em_value(measurement: &Measurement) -> Option<f64> {
match measurement.unit.as_str() {
"em" => Some(measurement.number),
"mu" => Some(measurement.number / 18.0),
"ex" => Some(measurement.number * 0.5),
_ => None,
}
}
pub fn math_choice_variant(
display: &[ParseNode],
text: &[ParseNode],
script: &[ParseNode],
scriptscript: &[ParseNode],
style: StyleLevel,
) -> Vec<ParseNode> {
match style {
StyleLevel::DisplayStyle => display.to_vec(),
StyleLevel::TextStyle => text.to_vec(),
StyleLevel::ScriptStyle => script.to_vec(),
StyleLevel::ScriptScriptStyle => scriptscript.to_vec(),
}
}