Fix space collapsing for explicit paragraphs (#5749)

This commit is contained in:
Laurenz 2025-01-24 13:31:03 +01:00 committed by GitHub
parent 26e65bfef5
commit 176b070c77
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
8 changed files with 32 additions and 9 deletions

View File

@ -729,8 +729,8 @@ fn finish(s: &mut State) -> SourceResult<()> {
} }
})?; })?;
// In math, spaces are top-level. // In paragraph and math realization, spaces are top-level.
if let RealizationKind::Math = s.kind { if matches!(s.kind, RealizationKind::LayoutPar | RealizationKind::Math) {
collapse_spaces(&mut s.sink, 0); collapse_spaces(&mut s.sink, 0);
} }

Binary file not shown.

Before

Width:  |  Height:  |  Size: 426 B

After

Width:  |  Height:  |  Size: 423 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 426 B

After

Width:  |  Height:  |  Size: 423 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 215 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 920 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 471 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 932 B

View File

@ -215,8 +215,30 @@ Welcome \ here. Does this work well?
#set text(hyphenate: false) #set text(hyphenate: false)
Lorem ipsum dolor #metadata(none) nonumy eirmod tempor. Lorem ipsum dolor #metadata(none) nonumy eirmod tempor.
--- par-show --- --- par-show-children ---
// This is only slightly cursed. // Variant 1: Prevent recursion by checking the children.
#let p = counter("p")
#let step = p.step()
#let nr = context p.display()
#show par: it => {
if it.body.at("children", default: ()).at(0, default: none) == step {
return it
}
par(step + [§#nr ] + it.body)
}
= A
B
C #parbreak() D
#block[E]
#block[F #parbreak() G]
--- par-show-styles ---
// Variant 2: Prevent recursion by observing a style.
#let revoke = metadata("revoke") #let revoke = metadata("revoke")
#show par: it => { #show par: it => {
if bibliography.title == revoke { return it } if bibliography.title == revoke { return it }
@ -229,11 +251,12 @@ Lorem ipsum dolor #metadata(none) nonumy eirmod tempor.
B B
C #parbreak() D C
#block[E] --- par-explicit-trim-space ---
A
#block[F #parbreak() G] #par[ B ]
--- issue-4278-par-trim-before-equation --- --- issue-4278-par-trim-before-equation ---
#set par(justify: true) #set par(justify: true)