Fix unstoppable empty footnote loop (#5354) (#5364)

This commit is contained in:
wznmickey 2024-11-05 03:27:25 -05:00 committed by GitHub
parent 5b11db0ef2
commit ada30cd5b1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 9 additions and 1 deletions

View File

@ -431,6 +431,9 @@ impl<'a, 'b> Composer<'a, 'b, '_, '_> {
// Find nested footnotes in the entry.
let nested = find_in_frames::<FootnoteElem>(&frames);
// Check if there are any non-empty frames.
let exist_non_empty_frame = frames.iter().any(|f| !f.is_empty());
// Extract the first frame.
let mut iter = frames.into_iter();
let first = iter.next().unwrap();
@ -440,7 +443,7 @@ impl<'a, 'b> Composer<'a, 'b, '_, '_> {
// possible, we then migrate the origin frame to the next region to
// uphold the footnote invariant (that marker and entry are on the same
// page). If not, we just queue the footnote for the next page.
if first.is_empty() {
if first.is_empty() && exist_non_empty_frame {
if migratable {
return Err(Stop::Finish(false));
} else {

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

View File

@ -286,3 +286,8 @@ B #footnote[b]
--- issue-4454-footnote-ref-numbering ---
// Test that footnote references are numbered correctly.
A #footnote(numbering: "*")[B]<fn>, C @fn, D @fn, E @fn.
--- issue-5354-footnote-empty-frame-infinite-loop ---
// Test whether an empty footnote would cause infinite loop
#show footnote.entry: it => {}
#lorem(3) #footnote[A footnote]