Skip to content

fix(odf): keep generated table of contents and index text - #4874

Closed
taran-dev4u wants to merge 1 commit into
docling-project:mainfrom
taran-dev4u:fix/odt-table-of-contents-4749
Closed

taran-dev4u wants to merge 1 commit into
docling-project:mainfrom
taran-dev4u:fix/odt-table-of-contents-4749

Conversation

@taran-dev4u

Copy link
Copy Markdown
Contributor

ODT table-of-content containers (text:table-of-content and related index elements) were matching the unhandled element branch in _add_odf_child(), dropping the index title and entry paragraphs from the converted document.

This change visits text:index-body children for table-of-content and other index containers, routing entries to ContentLayer.BODY in source order (or ContentLayer.INVISIBLE when text:display="none" is set).

Issue resolved by this Pull Request:
Resolves #4749

Checklist:

  • Documentation has been updated, if necessary.
  • Examples have been added, if necessary.
  • Tests have been added, if necessary.

Review evidence:

  • Before: with an ODT containing a generated table of contents, the index title and all entry paragraphs were dropped, exporting only surrounding body paragraphs.
  • After: index title and entries are extracted in reading order as text items in ContentLayer.BODY.
  • Tests: added unit tests in tests/test_backend_opendocument.py covering table-of-contents extraction, hidden TOCs, and illustration/table index containers. All 64 tests in test_backend_opendocument.py pass.
  • Checks: ruff check and ruff format --check pass on changed files.

Signed-off-by: Taran Mamidala <mamidalataran6333@gmail.com>
@github-actions

Copy link
Copy Markdown
Contributor

✅ DCO Check Passed

Thanks @taran-dev4u, all your commits are properly signed off. 🎉

@taran-dev4u
taran-dev4u marked this pull request as ready for review October 17, 2026 20:40
@mergify

mergify Bot commented Oct 17, 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) ai:possible-duplicate AI triage: another PR may fix the same problem bug Something isn't working odf Issue related to the OpenDocument format (ODT, ODS, ODP) backend labels Oct 17, 2026
@github-actions

Copy link
Copy Markdown
Contributor

AI triage (advisory)

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

The PR adds handling for ODT index containers (table of contents, illustration, table and other indexes) in _add_odf_child(). It keeps the index title and entry text in source order. Hidden indexes go to the invisible layer.

Topic labels added: bug, odf.

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

Possible duplicates

PR State Signal Assessment
#4750 open also references issue #4749; changes the same code duplicate: Both PRs fix #4749 by routing the same set of ODT index container tags into the existing child-visiting code in _add_odf_child(). They edit the same lines, so only one can be merged.

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

@taran-dev4u

Copy link
Copy Markdown
Contributor Author

Closing in favor of #4750.

@taran-dev4u
taran-dev4u deleted the fix/odt-table-of-contents-4749 branch October 17, 2026 20:44
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:possible-duplicate AI triage: another PR may fix the same problem bug Something isn't working odf Issue related to the OpenDocument format (ODT, ODS, ODP) backend

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ODT: a generated table of contents is dropped

1 participant