From 03d2ec9f813cb18c350de78614fcbc269b2dfc96 Mon Sep 17 00:00:00 2001 From: Alex Saveau Date: Thu, 13 Apr 2023 01:42:03 -0700 Subject: Strip trailing line breaks in math equations (#750) --- library/src/math/row.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'library/src') 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()); -- cgit v1.2.3