You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(toc_extractor): unstripped block.text in raw list causes false degenerate-structure detection, losing document sections #248
_detect_headers() in toc_extractor.py appends block.text (with leading/trailing whitespace) to the raw list without stripping. _is_degenerate_structure() then builds a distinct_titles set from these unstripped values. Two blocks with the same title but different whitespace (e.g. ' Introduction ' and 'Introduction') are counted as distinct titles, falsely triggering the degenerate-structure path and discarding all section structure.
Root Cause
ingestion/toc_extractor.py around line 274:
raw.append((level, block.text, page_num)) # ← block.text NOT stripped
The fix str(title).strip() IS applied at _derive_page_ranges (TocEntry creation), but that's too late — the degenerate check runs first on raw data.
Failure Scenario
A PDF has two heuristic header candidates on the same page: one block with text ' Introduction ' (leading/trailing spaces) and one with 'Introduction' (no spaces).
Both clamp to the same page_start, leaving one survivors entry.
Activity
piyushmakhija28 commentedon Jun 21, 2026
Fixed in PR #280 (Sprint R3/R4: fix(sprint-r3): root-cause fixes for all 39 bugs from code review round 3 + Sprint R4 round 4)