1 Commits

Author SHA1 Message Date
Rudy Celekli
cbed908f6a fix(textbook_struct): keep the higher-page chapter hit when deduping
_dedupe_keep_last documents 'keep the body hit (higher page)', but both
branches assigned by_title[title] = chapter unconditionally, so it actually
kept the last occurrence in list order. rebuild() iterates layout['pdf_info']
without sorting (unlike the sibling rebuild_from_headers_level, which sorts by
page_idx), so when pdf_info is not ascending the TOC hit (lower page) could be
listed last and win — giving the chapter the TOC start page and a wrong page
range. Compare page_idx and keep the higher one.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-10-26 10:52:35 -04:00