Tight lists only attach to preceding paragraphs, not blocks anymore (#4396)

This commit is contained in:
Laurenz 2024-06-16 09:48:03 +02:00 committed by GitHub
parent 1110b93564
commit f25308d1eb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
8 changed files with 28 additions and 7 deletions

View File

@ -126,12 +126,13 @@ pub struct VElem {
#[external]
pub weak: bool,
/// The element's weakness level, see also [`Behaviour`].
/// The spacing's weakness level, see also [`Behaviour`].
#[internal]
#[parse(args.named("weak")?.map(|v: bool| v as usize))]
pub weakness: usize,
/// Whether the element collapses if there is a parbreak in front.
/// Whether the spacing collapses if not immediately preceded by a
/// paragraph.
#[internal]
#[parse(Some(false))]
pub attach: bool,

View File

@ -385,16 +385,15 @@ impl<'a> FlowBuilder<'a> {
content: &'a Content,
styles: StyleChain<'a>,
) -> bool {
let last_was_par = self.1;
self.1 = false;
if content.is::<ParbreakElem>() {
self.1 = true;
return true;
}
let last_was_parbreak = self.1;
self.1 = false;
if let Some(elem) = content.to_packed::<VElem>() {
if !elem.attach(styles) || !last_was_parbreak {
if !elem.attach(styles) || last_was_par {
self.0.push(content, styles);
}
return true;
@ -434,6 +433,7 @@ impl<'a> FlowBuilder<'a> {
self.0.push(*par_spacing, styles);
self.0.push(content, styles);
self.0.push(*par_spacing, styles);
self.1 = true;
return true;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 884 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 225 B

After

Width:  |  Height:  |  Size: 234 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 968 B

After

Width:  |  Height:  |  Size: 1020 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

@ -145,3 +145,23 @@ World
--- issue-2530-list-item-panic ---
// List item (pre-emptive)
#list.item[Hello]
--- issue-1850-list-attach-spacing ---
// List attachment should only work with paragraphs, not other blocks.
#set page(width: auto)
#let part = box.with(stroke: 1pt, inset: 3pt)
#{
part[
$ x $
- A
]
part($ x $ + list[A])
part($ x $ + list[ A ])
part[
$ x $
- A
]
part($ x $ + parbreak() + list[A])
part($ x $ + parbreak() + parbreak() + list[A])
}