From 62567fc91e2d58d5d12457bbeddc5d7950d7c570 Mon Sep 17 00:00:00 2001 From: PgBiel <9021226+PgBiel@users.noreply.github.com> Date: Sun, 8 Dec 2024 13:35:54 -0300 Subject: [PATCH] Fix multiple footnotes in footnote entry (#5545) --- crates/typst-layout/src/flow/compose.rs | 15 ++++++++++++++- ...issue-5256-multiple-footnotes-in-footnote.png | Bin 0 -> 796 bytes tests/suite/layout/flow/footnote.typ | 4 ++++ 3 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 tests/ref/issue-5256-multiple-footnotes-in-footnote.png diff --git a/crates/typst-layout/src/flow/compose.rs b/crates/typst-layout/src/flow/compose.rs index 343b47833..9650a7bc1 100644 --- a/crates/typst-layout/src/flow/compose.rs +++ b/crates/typst-layout/src/flow/compose.rs @@ -470,7 +470,20 @@ impl<'a, 'b> Composer<'a, 'b, '_, '_> { // Lay out nested footnotes. for (_, note) in nested { - self.footnote(note, regions, flow_need, migratable)?; + match self.footnote(note, regions, flow_need, migratable) { + // This footnote was already processed or queued. + Ok(_) => {} + // Footnotes always request a relayout when processed for the + // first time, so we ignore a relayout request since we're + // about to do so afterwards. Without this check, the first + // inner footnote interrupts processing of the following ones. + Err(Stop::Relayout(_)) => {} + // Either of + // - A `Stop::Finish` indicating that the frame's origin element + // should migrate to uphold the footnote invariant. + // - A fatal error. + err => return err, + } } // Since we laid out a footnote, we need a relayout. diff --git a/tests/ref/issue-5256-multiple-footnotes-in-footnote.png b/tests/ref/issue-5256-multiple-footnotes-in-footnote.png new file mode 100644 index 0000000000000000000000000000000000000000..f9c1733515950a9a022e784c477d151273be14c6 GIT binary patch literal 796 zcmV+%1LOROP) z_4V%W^WER)_xJhV;OF=E`2GF;>+JB;)!ot4+qAa6@$vNV@bK#E@9pmL>gwu;hlktS z+vn))=;-LAq@-eEV&vrHSXfxKwY8d?pWfcytgNi9ueW-8ft#G7k&~Nxe1xZ|v9q(a z)Yjf_ae2?t*+@!KaB_Oh&(~yTZq3cnl9Zgs$k5*2;*^z{%F4|4_V)Ah^M!|x$;;EE zrKzi|u!e|`%+1l8oS>+8I{ys4?F%F4>h%+x|eOw-fTu&}VGsCb) zO-)HjNpW#;*x1;XmX?o?kMHmAudlB?Jw5I1?SO!QQBhI!^z=?nPF-DH{{H@`sHouJ z;COg=-QC^k>FN9X``_Q+=I8D6^Y;4s`uqF*ii(Qj$FKwd00BrzL_t(|+U?gxR|7E= zhT)H72HN6Mytuo&ySuwvTWFC&U8X;r*|O=XB!_aJWdAO5?mZ_UgphdfeL;%Tvnxo! z8zhD6>MtP$=bXY~Fve)55JLW#XiWG$NiosGBobwCKSI4YQtpb$oJe zc1dh_bc8jvw2n>8&n$`!n~bc{sMe@c(+gt5oasFKs3fVZa3DQFEYY+emL$SSU404e)>>USU>|#;!LaV z==2055H8cw-Sy;twnMZGQ!T7EpBJLBR1>WB#|J4Z(`tkBRYo}fSnl2q-p-Mg4Z+y%cHkXAM8X2`yP%U0#_}4FE+f3MYA!9IIU|IS aAHD(Hcs_t>m%3&E0000, C @fn, D @fn, E @fn. // Test whether an empty footnote would cause infinite loop #show footnote.entry: it => {} #lorem(3) #footnote[A footnote] + +--- issue-5256-multiple-footnotes-in-footnote --- +// Test whether all footnotes inside another footnote are listed. +#footnote[#footnote[A]#footnote[B]#footnote[C]]