Align point and linebreak should not increase math row height (#4306)

This commit is contained in:
Leedehai 2024-06-04 11:30:43 -04:00 committed by GitHub
parent 9adcd9a1f8
commit df6e347bc5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 24 additions and 2 deletions

View File

@ -117,11 +117,19 @@ impl MathRun {
}
pub fn ascent(&self) -> Abs {
self.iter().map(MathFragment::ascent).max().unwrap_or_default()
self.iter()
.filter(|e| affects_row_height(e))
.map(|e| e.ascent())
.max()
.unwrap_or_default()
}
pub fn descent(&self) -> Abs {
self.iter().map(MathFragment::descent).max().unwrap_or_default()
self.iter()
.filter(|e| affects_row_height(e))
.map(|e| e.descent())
.max()
.unwrap_or_default()
}
pub fn class(&self) -> MathClass {
@ -386,3 +394,7 @@ impl MathRunFrameBuilder {
frame
}
}
fn affects_row_height(fragment: &MathFragment) -> bool {
!matches!(fragment, MathFragment::Align | MathFragment::Linebreak)
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 282 B

View File

@ -256,6 +256,16 @@ $ q &= sum_k ln A \
],
)
--- issue-4187-alignment-point-affects-row-height ---
// In this bug, a row of "-" only should have a very small height; but
// after adding an alignment point "&", the row gains a larger height.
// We need to test alignment point "&" does not affect a row's height.
#box($ - - $, fill: silver)
#box($ - - $, fill: silver) \
#box($ a \ - - $, fill: silver)
#box($ &- - \ &a $, fill: silver)
#box($ &a \ &- - $, fill: silver)
--- issue-numbering-hint ---
// In this bug, the hint and error messages for an equation
// being reference mentioned that it was a "heading" and was