Fix tags at the start of paragraphs (#4978)

Co-authored-by: Martin Haug <mhaug@live.de>
This commit is contained in:
Laurenz 2024-09-17 17:54:15 +02:00 committed by GitHub
parent ab8295c07d
commit 92ec566018
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 12 additions and 1 deletions

View File

@ -58,7 +58,13 @@ impl<'a> Preparation<'a> {
/// Iterate over the items that intersect the given `sliced` range. /// Iterate over the items that intersect the given `sliced` range.
pub fn slice(&self, sliced: Range) -> impl Iterator<Item = &(Range, Item<'a>)> { pub fn slice(&self, sliced: Range) -> impl Iterator<Item = &(Range, Item<'a>)> {
let start = self.indices.get(sliced.start).copied().unwrap_or(0); // Usually, we don't want empty-range items at the start of the line
// (because they will be part of the previous line), but for the first
// line, we need to keep them.
let start = match sliced.start {
0 => 0,
n => self.indices.get(n).copied().unwrap_or(0),
};
self.items[start..].iter().take_while(move |(range, _)| { self.items[start..].iter().take_while(move |(range, _)| {
range.start < sliced.end || range.end <= sliced.end range.start < sliced.end || range.end <= sliced.end
}) })

View File

@ -101,3 +101,8 @@ Lorem ipsum dolor #metadata(none) nonumy eirmod tempor.
--- issue-4938-par-bad-ratio --- --- issue-4938-par-bad-ratio ---
#set par(justify: true) #set par(justify: true)
#box($k in NN_0$) #box($k in NN_0$)
--- issue-4770-par-tag-at-start ---
#h(0pt) #box[] <a>
#context test(query(<a>).len(), 1)