diff --git a/crates/formats/src/mathml.rs b/crates/formats/src/mathml.rs
index cf5d8fa3e..d9974b1fc 100644
--- a/crates/formats/src/mathml.rs
+++ b/crates/formats/src/mathml.rs
@@ -175,8 +175,16 @@ fn node(n: &MNode, o: &mut String, depth: usize, eq_arr: bool) {
o.push_str("");
group(base, o, depth);
o.push_str("");
- group(sub, o, depth);
- group(sup, o, depth);
+ if sub.is_empty() {
+ o.push_str("");
+ } else {
+ group(sub, o, depth);
+ }
+ if sup.is_empty() {
+ o.push_str("");
+ } else {
+ group(sup, o, depth);
+ }
o.push_str("");
}
},
@@ -443,7 +451,8 @@ pub fn local(name: &str) -> &str {
/// The linear format of a `