summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--library/src/math/row.rs6
-rw-r--r--tests/ref/math/multiline.pngbin8165 -> 13474 bytes
-rw-r--r--tests/typ/math/multiline.typ21
3 files changed, 26 insertions, 1 deletions
diff --git a/library/src/math/row.rs b/library/src/math/row.rs
index 26172303..ce9bc94a 100644
--- a/library/src/math/row.rs
+++ b/library/src/math/row.rs
@@ -127,11 +127,15 @@ impl MathRow {
TIGHT_LEADING.scaled(ctx)
};
- let rows: Vec<_> = fragments
+ let mut rows: Vec<_> = fragments
.split(|frag| matches!(frag, MathFragment::Linebreak))
.map(|slice| Self(slice.to_vec()))
.collect();
+ if matches!(rows.last(), Some(row) if row.0.is_empty()) {
+ rows.pop();
+ }
+
let width = rows.iter().map(|row| row.width()).max().unwrap_or_default();
let points = alignments(&rows);
let mut frame = Frame::new(Size::zero());
diff --git a/tests/ref/math/multiline.png b/tests/ref/math/multiline.png
index 94ef1196..50f611b2 100644
--- a/tests/ref/math/multiline.png
+++ b/tests/ref/math/multiline.png
Binary files differ
diff --git a/tests/typ/math/multiline.typ b/tests/typ/math/multiline.typ
index 1d268fae..4f42ea63 100644
--- a/tests/typ/math/multiline.typ
+++ b/tests/typ/math/multiline.typ
@@ -33,3 +33,24 @@ $ "abc" &= c \
---
// Test multiline subscript.
$ sum_(n in NN \ n <= 5) n = (5(5+1))/2 = 15 $
+
+---
+// Test no trailing line break.
+$
+"abc" &= c
+$
+No trailing line break.
+
+---
+// Test single trailing line break.
+$
+"abc" &= c \
+$
+One trailing line break.
+
+---
+// Test multiple trailing line breaks.
+$
+"abc" &= c \ \ \
+$
+Multiple trailing line breaks.