Skip to content

fix(odf): keep footnotes out of the text of ODT table cells - #5496

Merged
dolfim-ibm merged 1 commit into
docling-project:mainfrom
67-luck:fix/odt-table-cell-footnote
Nov 24, 2026
Merged

dolfim-ibm merged 1 commit into
docling-project:mainfrom
67-luck:fix/odt-table-cell-footnote

Conversation

@67-luck

@67-luck 67-luck commented Nov 20, 2026

Copy link
Copy Markdown
Contributor

A footnote or endnote cited in an ODT table cell was spliced into the cell text. The cell text paths read paragraphs with odfdo's text_recursive, which renders a text:note as "citation. body". #4375 fixed this for paragraph text: _odf_text_runs skips the note, and _add_footnotes adds the body as its own FOOTNOTE item. Table cells, however, read their text through _odf_element_text_lines and _odf_cell_has_rich_content. So the note body was still glued to the cell text, and the same body was also added as a footnote item.

The new helper _odf_text_without_notes returns text_recursive without the notes. It deletes them from a clone; odfdo's Element.delete keeps the tail text by default. An element without a note goes through the old code unchanged. List items are not changed, because their text already comes from the text runs.

Checklist:

  • Documentation has been updated, if necessary. (not needed)
  • Examples have been added, if necessary. (not needed)
  • Tests have been added, if necessary.

Review evidence:

Source: a table cell <text:p>42 EUR<text:note …><text:note-body><text:p>Audited figures.</text:p></text:note-body></text:note></text:p>.

Cell text Footnote items
Before 42 EUR1. Audited figures. ["Audited figures."]
After 42 EUR ["Audited figures."]
  • New test_odt_footnote_in_table_cell_is_not_spliced in tests/test_backend_opendocument.py. It fails on main and passes with this change.
  • pytest tests/test_backend_opendocument.py: 102 passed, including test_e2e_odf_conversions. No reference data changes.
  • ruff format --check and ruff check (v0.17.2) are clean on the changed files. ty check docling/backend/opendocument_backend.py reports the same 48 existing diagnostics as on main.
  • Not run: the full test suite, make validate (no make on my Windows machine), tach, dprint.

I used an AI assistant while working on this. I reproduced the bug, checked the document tree before and after, and ran the tests myself.

🤖 Generated with Claude Code

A footnote or endnote cited in a table cell was read into the cell text
with odfdo's text_recursive, which renders a text:note as "citation.
body". The cell "42 EUR" with a footnote became "42 EUR1. Audited
figures.", and the body was also added as its own footnote item.
Paragraph text already skips the note (docling-project#4375). Leave the note out of
the cell text in the same way.

Signed-off-by: 67-luck <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
@github-actions

Copy link
Copy Markdown
Contributor

✅ DCO Check Passed

Thanks @67-luck, all your commits are properly signed off. 🎉

@mergify

mergify Bot commented Nov 20, 2026

Copy link
Copy Markdown
Contributor

Merge Protections

🟢 Merge protection satisfied — ready to merge.

Show 1 satisfied protection

🟢 Enforce conventional commit

Make sure that we follow https://www.conventionalcommits.org/en/v1.0.0/

  • title ~= ^(fix|feat|docs|style|refactor|perf|test|build|ci|chore|revert)(?:\(.+\))?(!)?:

@github-actions github-actions Bot added ai:ci-safe AI triage found no CI-safety concern (advisory) bug Something isn't working odf Issue related to the OpenDocument format (ODT, ODS, ODP) backend priority:medium labels Nov 20, 2026
@github-actions

Copy link
Copy Markdown
Contributor

AI triage (advisory)

Checked commit d88bd0367e. The analysis read the diff only. It did not run code from this pull request.

The PR keeps footnote and endnote text out of ODT table cell text. It adds the helper _odf_text_without_notes and uses it in _odf_element_text_lines and _odf_cell_has_rich_content. A new test covers a footnote in a table cell.

Topic labels added: bug, odf, priority:medium.

CI safety: no concern found. A maintainer must still approve CI.

1 related pull request(s) in the same code
PR State Signal Assessment
#4375 merged referenced as #4375 related: PR 4375 is merged. It fixed footnote splicing in paragraph text with _odf_text_runs. This PR fixes the table cell text paths, which that change did not cover.

The ai:* labels are advisory. They do not approve CI and they do not add tests:full. A new push runs this check again.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AI first review (advisory): no blocker found

This review covers the full diff at d88bd0367e. It read the code and did not run it.

I found no defect. All three table-cell paths that read paragraph text (_odf_element_text_lines and the Header/Paragraph checks in _odf_cell_has_rich_content) now use _odf_text_without_notes. The regression test checks both the cell text and the single footnote item. I could not read the odfdo source because .venv has no installed packages. I did not verify the claim that Element.delete keeps tail text. The same call is already used for annotations in docling/backend/opendocument_backend.py.

A maintainer makes the merge decision. This review never approves the pull request.

@github-actions github-actions Bot added the ai:review-lgtm AI first review found no blocker or major issue (advisory) label Nov 20, 2026
@codecov

codecov Bot commented Nov 20, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 83.33333% with 2 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
docling/backend/opendocument_backend.py 83.33% 2 Missing ⚠️

📢 Thoughts on this report? Let us know!

@dolfim-ibm dolfim-ibm left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@dolfim-ibm
dolfim-ibm merged commit 3ce28ac into docling-project:main Nov 24, 2026
34 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai:ci-safe AI triage found no CI-safety concern (advisory) ai:review-lgtm AI first review found no blocker or major issue (advisory) bug Something isn't working odf Issue related to the OpenDocument format (ODT, ODS, ODP) backend priority:medium

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants