mirror of
https://github.com/docling-project/docling-core.git
synced 2026-11-18 20:27:00 +00:00
* fix(serializer): serialize table footnotes in Markdown and HTML (#496) Since footnote handling was delegated to the parent FloatingItem, table footnotes were silently dropped from Markdown and HTML output (and from chunking, which relies on serialization). The `serialize_footnotes` hook existed on the doc serializer but was never invoked by the table serializers, so the footnotes stored on `TableItem.footnotes` never reached the output. - MarkdownTableSerializer: emit the table's footnotes after the table body, mirroring the existing caption handling. - HTMLTableSerializer: emit the footnotes after the closing </table>. - HTMLDocSerializer: add a serialize_footnotes override so footnotes are HTML-escaped and wrapped in <div class="footnote"> (the base method returns raw text, matching the existing serialize_captions override). - Add a regression test asserting table footnotes survive both exports. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Signed-off-by: Kavishka Rambukwella <90164480+Kavishkagaya@users.noreply.github.com> * fix(serializer): serialize picture footnotes in Markdown and HTML Picture footnotes were dropped the same way as table footnotes: the picture serializers never called serialize_footnotes. In HTML they go inside <figure>, so every FloatingItem keeps its footnotes in its block. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Kavishkagaya <kavishkarambukwella@gmail.com> * fix(serializer): serialize code footnotes in Markdown and HTML docling attaches footnotes to code blocks as well as tables and pictures, and they were dropped the same way. HTML also dropped code captions: HTMLTextSerializer collected them in res_parts but returned only the code text. A code block with captions or footnotes is now wrapped in <figure>, where <figcaption> is valid. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Kavishkagaya <kavishkarambukwella@gmail.com> * fix(serializer): address review on footnote serialization - HTMLTableSerializer: build the table text and the footnotes separately, so the footnote goes into text_res and res_parts in one place. - HTML footnote divs are joined with "" (HTML blocks, not text). - HTML code blocks are wrapped in <figure> whenever they have captions or footnotes, also when the code text is empty. - Markdown footnotes are one paragraph each instead of joined by a space. - Tests: one each for table, picture and code footnotes, with HTML escaping and the joins; drop the data-model assertion. - Ground truth from a real conversion of the PDF in #496. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Co-Authored-By: Cesar Berrospi Ramis <ceb@zurich.ibm.com> Signed-off-by: Kavishkagaya <kavishkarambukwella@gmail.com> Signed-off-by: Cesar Berrospi Ramis <ceb@zurich.ibm.com> * fix(chunker): keep table footnotes in HierarchicalChunker chunks TripletTableSerializer has its own table output and never called serialize_footnotes, so table footnotes were missing from chunks. Ported from the chunker change in #545. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Kavishkagaya <kavishkarambukwella@gmail.com> * fix(serializer): keep Markdown table footnotes when the table label is excluded MarkdownTableSerializer called serialize_footnotes inside the "item not excluded" guard, so footnotes were dropped when only the table label was filtered out. The Markdown picture serializer and both HTML serializers emit them regardless, as they do for captions. Move the call out of the guard to match. Add a regression test for the excluded-label case and extend test_chunk_table_keeps_footnotes to cover picture and code footnotes. Signed-off-by: Cesar Berrospi Ramis <ceb@zurich.ibm.com> --------- Signed-off-by: Kavishka Rambukwella <90164480+Kavishkagaya@users.noreply.github.com> Signed-off-by: Kavishkagaya <kavishkarambukwella@gmail.com> Signed-off-by: Cesar Berrospi Ramis <ceb@zurich.ibm.com> Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Co-authored-by: Cesar Berrospi Ramis <ceb@zurich.ibm.com>