Fix space collapsing for explicit paragraphs (#5749)
@ -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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Before Width: | Height: | Size: 426 B After Width: | Height: | Size: 423 B |
Before Width: | Height: | Size: 426 B After Width: | Height: | Size: 423 B |
BIN
tests/ref/par-explicit-trim-space.png
Normal file
After Width: | Height: | Size: 215 B |
BIN
tests/ref/par-show-children.png
Normal file
After Width: | Height: | Size: 920 B |
BIN
tests/ref/par-show-styles.png
Normal file
After Width: | Height: | Size: 471 B |
Before Width: | Height: | Size: 932 B |
@ -215,14 +215,16 @@ 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 revoke = metadata("revoke")
|
#let p = counter("p")
|
||||||
|
#let step = p.step()
|
||||||
|
#let nr = context p.display()
|
||||||
#show par: it => {
|
#show par: it => {
|
||||||
if bibliography.title == revoke { return it }
|
if it.body.at("children", default: ()).at(0, default: none) == step {
|
||||||
set bibliography(title: revoke)
|
return it
|
||||||
let p = counter("p")
|
}
|
||||||
par[#p.step() §#context p.display() #it.body]
|
par(step + [§#nr ] + it.body)
|
||||||
}
|
}
|
||||||
|
|
||||||
= A
|
= A
|
||||||
@ -235,6 +237,27 @@ C #parbreak() D
|
|||||||
|
|
||||||
#block[F #parbreak() G]
|
#block[F #parbreak() G]
|
||||||
|
|
||||||
|
--- par-show-styles ---
|
||||||
|
// Variant 2: Prevent recursion by observing a style.
|
||||||
|
#let revoke = metadata("revoke")
|
||||||
|
#show par: it => {
|
||||||
|
if bibliography.title == revoke { return it }
|
||||||
|
set bibliography(title: revoke)
|
||||||
|
let p = counter("p")
|
||||||
|
par[#p.step()§#context p.display() #it.body]
|
||||||
|
}
|
||||||
|
|
||||||
|
= A
|
||||||
|
|
||||||
|
B
|
||||||
|
|
||||||
|
C
|
||||||
|
|
||||||
|
--- par-explicit-trim-space ---
|
||||||
|
A
|
||||||
|
|
||||||
|
#par[ B ]
|
||||||
|
|
||||||
--- issue-4278-par-trim-before-equation ---
|
--- issue-4278-par-trim-before-equation ---
|
||||||
#set par(justify: true)
|
#set par(justify: true)
|
||||||
#lorem(6) aa $a = c + b$
|
#lorem(6) aa $a = c + b$
|
||||||
|