Tight lists only attach to preceding paragraphs, not blocks anymore (#4396)
@ -126,12 +126,13 @@ pub struct VElem {
|
|||||||
#[external]
|
#[external]
|
||||||
pub weak: bool,
|
pub weak: bool,
|
||||||
|
|
||||||
/// The element's weakness level, see also [`Behaviour`].
|
/// The spacing's weakness level, see also [`Behaviour`].
|
||||||
#[internal]
|
#[internal]
|
||||||
#[parse(args.named("weak")?.map(|v: bool| v as usize))]
|
#[parse(args.named("weak")?.map(|v: bool| v as usize))]
|
||||||
pub weakness: 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]
|
#[internal]
|
||||||
#[parse(Some(false))]
|
#[parse(Some(false))]
|
||||||
pub attach: bool,
|
pub attach: bool,
|
||||||
|
@ -385,16 +385,15 @@ impl<'a> FlowBuilder<'a> {
|
|||||||
content: &'a Content,
|
content: &'a Content,
|
||||||
styles: StyleChain<'a>,
|
styles: StyleChain<'a>,
|
||||||
) -> bool {
|
) -> bool {
|
||||||
|
let last_was_par = self.1;
|
||||||
|
self.1 = false;
|
||||||
|
|
||||||
if content.is::<ParbreakElem>() {
|
if content.is::<ParbreakElem>() {
|
||||||
self.1 = true;
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
let last_was_parbreak = self.1;
|
|
||||||
self.1 = false;
|
|
||||||
|
|
||||||
if let Some(elem) = content.to_packed::<VElem>() {
|
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);
|
self.0.push(content, styles);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@ -434,6 +433,7 @@ impl<'a> FlowBuilder<'a> {
|
|||||||
self.0.push(*par_spacing, styles);
|
self.0.push(*par_spacing, styles);
|
||||||
self.0.push(content, styles);
|
self.0.push(content, styles);
|
||||||
self.0.push(*par_spacing, styles);
|
self.0.push(*par_spacing, styles);
|
||||||
|
self.1 = true;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BIN
tests/ref/issue-1850-list-attach-spacing.png
Normal file
After Width: | Height: | Size: 884 B |
Before Width: | Height: | Size: 225 B After Width: | Height: | Size: 234 B |
Before Width: | Height: | Size: 968 B After Width: | Height: | Size: 1020 B |
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 11 KiB |
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.1 KiB |
@ -145,3 +145,23 @@ World
|
|||||||
--- issue-2530-list-item-panic ---
|
--- issue-2530-list-item-panic ---
|
||||||
// List item (pre-emptive)
|
// List item (pre-emptive)
|
||||||
#list.item[Hello]
|
#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])
|
||||||
|
}
|
||||||
|