use vize_atelier_core::Namespace;
pub(crate) fn get_namespace(tag: &str, parent: Option<&str>) -> Namespace {
if vize_carton::is_svg_tag(tag) {
return Namespace::Svg;
}
if vize_carton::is_math_ml_tag(tag) {
return Namespace::MathMl;
}
if let Some(parent_tag) = parent {
let svg_to_html = matches!(parent_tag, "foreignObject" | "desc" | "title");
if vize_carton::is_svg_tag(parent_tag) && !svg_to_html {
return Namespace::Svg;
}
let mathml_to_html = matches!(
parent_tag,
"annotation-xml" | "mi" | "mo" | "mn" | "ms" | "mtext"
);
if vize_carton::is_math_ml_tag(parent_tag) && !mathml_to_html {
return Namespace::MathMl;
}
}
Namespace::Html
}