summaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
authorLeedehai <18319900+Leedehai@users.noreply.github.com>2024-07-15 05:54:54 -0400
committerGitHub <noreply@github.com>2024-07-15 09:54:54 +0000
commitf0407d4949cce8014e2a4fdef8c00c955d870127 (patch)
treea5cc7754e76ea8f342a7873c796f81b2a69cf041 /crates
parentac322e342b4736bea189f5e7ac39561c0e5a3127 (diff)
Wrapping with parens should not push superscripts higher (#4545)
Co-authored-by: Laurenz <laurmaedje@gmail.com>
Diffstat (limited to 'crates')
-rw-r--r--crates/typst/src/math/row.rs15
1 files changed, 12 insertions, 3 deletions
diff --git a/crates/typst/src/math/row.rs b/crates/typst/src/math/row.rs
index 5234ca2c..60afe64e 100644
--- a/crates/typst/src/math/row.rs
+++ b/crates/typst/src/math/row.rs
@@ -159,10 +159,19 @@ impl MathRun {
pub fn into_fragment(self, ctx: &MathContext, styles: StyleChain) -> MathFragment {
if self.0.len() == 1 {
- self.0.into_iter().next().unwrap()
- } else {
- FrameFragment::new(ctx, styles, self.into_frame(ctx, styles)).into()
+ return self.0.into_iter().next().unwrap();
}
+
+ // Fragments without a math_size are ignored: the notion of size do not
+ // apply to them, so their text-likeness is meaningless.
+ let text_like = self
+ .iter()
+ .filter(|e| e.math_size().is_some())
+ .all(|e| e.is_text_like());
+
+ FrameFragment::new(ctx, styles, self.into_frame(ctx, styles))
+ .with_text_like(text_like)
+ .into()
}
/// Returns a builder that lays out the [`MathFragment`]s into a possibly