mirror of
https://github.com/typst/typst
synced 2025-05-15 01:25:28 +08:00
Strip trailing line breaks in math equations (#750)
This commit is contained in:
parent
a066a3d283
commit
03d2ec9f81
@ -127,11 +127,15 @@ impl MathRow {
|
|||||||
TIGHT_LEADING.scaled(ctx)
|
TIGHT_LEADING.scaled(ctx)
|
||||||
};
|
};
|
||||||
|
|
||||||
let rows: Vec<_> = fragments
|
let mut rows: Vec<_> = fragments
|
||||||
.split(|frag| matches!(frag, MathFragment::Linebreak))
|
.split(|frag| matches!(frag, MathFragment::Linebreak))
|
||||||
.map(|slice| Self(slice.to_vec()))
|
.map(|slice| Self(slice.to_vec()))
|
||||||
.collect();
|
.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 width = rows.iter().map(|row| row.width()).max().unwrap_or_default();
|
||||||
let points = alignments(&rows);
|
let points = alignments(&rows);
|
||||||
let mut frame = Frame::new(Size::zero());
|
let mut frame = Frame::new(Size::zero());
|
||||||
|
Binary file not shown.
Before Width: | Height: | Size: 8.0 KiB After Width: | Height: | Size: 13 KiB |
@ -33,3 +33,24 @@ $ "abc" &= c \
|
|||||||
---
|
---
|
||||||
// Test multiline subscript.
|
// Test multiline subscript.
|
||||||
$ sum_(n in NN \ n <= 5) n = (5(5+1))/2 = 15 $
|
$ 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.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user