Skip to content

fix: temporarily disable TOC detection until it is complete#639

Merged
bundolee merged 1 commit into
mainfrom
fix/disable-toc-detection
Jul 14, 2026
Merged

fix: temporarily disable TOC detection until it is complete#639
bundolee merged 1 commit into
mainfrom
fix/disable-toc-detection

Conversation

@bundolee

@bundolee bundolee commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

Objective

PDF/UA-2 validation fails on documents where a table of contents is detected. A detected TOC cannot currently become a conformant structure: PDF/UA-2 clause 8.2.5.8.1 requires each TOCI to identify the section it references via a target, but the pipeline never resolves that target, so the tagged output carries no valid reference and fails validation. The detector is also triggered too eagerly — any line ending in a number looks like a TOC entry — so it can restructure ordinary body text.

Approach

Turn TOC detection off at its single call site (DocumentProcessor) until it is finished, rather than shipping a half-working table of contents. A partial TOC is worse than none: an entry that points nowhere (or to the wrong place) sends a screen reader astray, and the false positives corrupt normal content. Only the call is commented out — TableOfContentsProcessor stays in the tree, so re-enabling is a one-line change once entry-target resolution and detection precision are complete. With detection off, the same text is tagged as ordinary paragraphs, which validates cleanly.

Some additional hardening for the detector is tracked in the internal tasks tracker and should land before re-enabling.

Evidence

Rebuilt core with detection disabled and converted a document that previously triggered TOC detection.

Scenario Expected Actual
Doc that previously produced TOC/TOCI, UA-1/UA-2 veraPDF pass, no TOC/TOCI in struct tree 1/1 pass; struct tree has 0 TOC, 0 TOCI, text tagged as 7 <P>
Normal (non-TOC) document Unchanged output No regression — every text line flows through the existing paragraph path

@MaximPlusov — while checking veraPDF conformance I found that the TOC detection you added produces a struct tree that fails PDF/UA-2 (clause 8.2.5.8.1): each TOCI needs to identify its reference target, but TOCIInfo's destination is never populated, so there is no valid /Ref to emit. Downstream I could only work around it by downgrading TOC items to plain paragraphs, which drops the TOC semantics entirely — so that isn't a real fix either.

My suggestion is to disable the feature for now and re-enable it once the target/destination resolution is in place (a couple of follow-up items are tracked in the internal tasks tracker). This PR just comments out the call; the processor stays in the tree so bringing it back is trivial. Happy to collaborate on the proper implementation — I think the right end state is resolving the entry target and tagging as L/LI (PDF/UA-2 no longer defines TOC/TOCI and expects list structures). What do you think?

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Temporarily disabled automatic table-of-contents detection to prevent incorrect processing of documents.
    • Other cross-page document structure processing remains unchanged.

Objective: PDF/UA-2 validation fails on documents where a table of contents
is detected. The detected TOC cannot become a conformant structure: each entry
must point at the section it references, but the pipeline never resolves that
target, so the tagged output has no valid reference and fails clause 8.2.5.8.1.
On top of that the detector is triggered too eagerly (any line ending in a
number looks like a TOC entry), so it can even restructure ordinary body text.

Approach: Turn the feature off at its single call site until it is finished,
rather than shipping a half-working table of contents. A partial TOC is worse
than none — an entry that points nowhere (or to the wrong place) sends a screen
reader astray, and the false positives corrupt normal content. Detection is
only commented out (the processor stays in the tree) so re-enabling is a
one-line change once entry-target resolution and detection precision are done.
With it off, the same text is tagged as ordinary paragraphs, which validates
cleanly.

Evidence: Rebuilt core with detection disabled and converted a document that
previously triggered TOC detection.
Before: TOC/TOCI elements emitted with no target -> PDF/UA-2 clause 8.2.5.8.1
  failure (each TOCI must identify its reference target).
After: veraPDF 1/1 pass; struct tree contains 0 TOC and 0 TOCI elements, the
  same text tagged as 7 <P> paragraphs. No regression to normal documents
  (every text line flows through the existing paragraph path).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: dd899ec2-f01f-4e53-87aa-aba084b80148

📥 Commits

Reviewing files that changed from the base of the PR and between fcf430e and d51edec.

📒 Files selected for processing (1)
  • java/opendataloader-pdf-core/src/main/java/org/opendataloader/pdf/processors/DocumentProcessor.java

Walkthrough

Table-of-contents detection is temporarily disabled in DocumentProcessor.processDocument. Other structured cross-page processing remains unchanged.

Changes

TOC processing change

Layer / File(s) Summary
Disable TOC detection
java/opendataloader-pdf-core/src/main/java/org/opendataloader/pdf/processors/DocumentProcessor.java
Removes the TableOfContentsProcessor invocation and documents that TOC detection is temporarily disabled; other cross-page processing remains intact.

Estimated code review effort: 2 (Simple) | ~5 minutes

Possibly related PRs

Suggested reviewers: maximplusov, lonelymidoriya, hnc-jglee, hyunhee-jo

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the change: TOC detection was temporarily disabled until the implementation is complete.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@bundolee
bundolee merged commit bbeeb81 into main Jul 14, 2026
8 checks passed
@bundolee
bundolee deleted the fix/disable-toc-detection branch July 14, 2026 08:45
@codecov

codecov Bot commented Jul 14, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant