diff --git a/library/src/layout/par.rs b/library/src/layout/par.rs index 7e43b43f7..0ad9e1718 100644 --- a/library/src/layout/par.rs +++ b/library/src/layout/par.rs @@ -83,15 +83,16 @@ pub struct ParElem { #[default] pub linebreaks: Smart, - /// The indent the first line of a consecutive paragraph should have. + /// The indent the first line of a paragraph should have. /// - /// The first paragraph on a page will never be indented. + /// Only the first line of a consecutive paragraph will be intended (not + /// the first one in a block or on the page). /// - /// By typographic convention, paragraph breaks are indicated by either some - /// space between paragraphs or indented first lines. Consider turning the - /// [paragraph spacing]($func/block.spacing) off when using this property - /// (e.g. using `[#show par: set block(spacing: 0pt)]`). - #[resolve] + /// By typographic convention, paragraph breaks are indicated either by some + /// space between paragraphs or by indented first lines. Consider reducing + /// the [paragraph spacing]($func/block.spacing) to the [`leading`] when + /// using this property (e.g. using + /// `[#show par: set block(spacing: 0.65em)]`). pub first_line_indent: Length, /// The indent all but the first line of a paragraph should have. @@ -498,27 +499,14 @@ fn collect<'a>( let mut spans = SpanMapper::new(); let mut iter = children.iter().peekable(); - if consecutive { - let first_line_indent = ParElem::first_line_indent_in(*styles); - if !first_line_indent.is_zero() - && children - .iter() - .find_map(|child| { - if child.with::().map_or(false, |behaved| { - behaved.behaviour() == Behaviour::Ignorant - }) { - None - } else if child.is::() || child.is::() { - Some(true) - } else { - Some(false) - } - }) - .unwrap_or_default() - { - full.push(SPACING_REPLACE); - segments.push((Segment::Spacing(first_line_indent.into()), *styles)); - } + let first_line_indent = ParElem::first_line_indent_in(*styles); + if !first_line_indent.is_zero() + && consecutive + && AlignElem::alignment_in(*styles).x.resolve(*styles) + == TextElem::dir_in(*styles).start().into() + { + full.push(SPACING_REPLACE); + segments.push((Segment::Spacing(first_line_indent.into()), *styles)); } let hang = ParElem::hanging_indent_in(*styles); diff --git a/tests/ref/layout/par-indent.png b/tests/ref/layout/par-indent.png index 6e5e25b66..233529256 100644 Binary files a/tests/ref/layout/par-indent.png and b/tests/ref/layout/par-indent.png differ diff --git a/tests/typ/layout/par-indent.typ b/tests/typ/layout/par-indent.typ index 4890e5dcf..787891816 100644 --- a/tests/typ/layout/par-indent.typ +++ b/tests/typ/layout/par-indent.typ @@ -10,7 +10,7 @@ The first paragraph has no indent. But the second one does. #box(image("/tiger.jpg", height: 6pt)) -starts a paragraph without indent. +starts a paragraph, also with indent. #align(center, image("/rhino.png", width: 1cm)) @@ -28,7 +28,6 @@ starts a paragraph without indent. ثم يصبح النص رطبًا وقابل للطرق ويبدو المستند رائعًا. - --- // This is madness. #set par(first-line-indent: 12pt)