summaryrefslogtreecommitdiff
path: root/library
diff options
context:
space:
mode:
authorAlex Saveau <saveau.alexandre@gmail.com>2023-04-13 01:42:03 -0700
committerGitHub <noreply@github.com>2023-04-13 10:42:03 +0200
commit03d2ec9f813cb18c350de78614fcbc269b2dfc96 (patch)
tree5f3b42b20b9cb454dd0a1e1adb33780aad657439 /library
parenta066a3d2831bc8e643349a54880671e9c7d11e0f (diff)
Strip trailing line breaks in math equations (#750)
Diffstat (limited to 'library')
-rw-r--r--library/src/math/row.rs6
1 files changed, 5 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());