7 Commits

Author SHA1 Message Date
Bingxi Zhao (Frank)
fa9d7aba70 Merge pull request #2058 into validated PR integration 2026-10-29 00:56:13 +08:00
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
Rudy Celekli
7842bafc0e fix(textbook_struct): keep two-char 单元 chapter token intact
The running-header normalizer's unit group used the character class
[课章节单元], which matches a single character. A 单元 (unit) token was
split: only 单 was captured and the orphaned 元 leaked into the chapter
name, so 第1单元 导论 normalized to 第1单 元 导论. The malformed title then
failed UNIT_RE_MAP[单元] matching, dropping header-embedded 单元 chapters
during rebuild. The function docstring already promises the canonical
第N单元 章名 shape. Match the two-char token first: 单元|[课章节].

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-10-26 10:21:21 -04:00
Bingxi Zhao (Frank)
98529ad0c7 fix(chat, text): replay the visible failed turn and retain repeated section titles 2026-09-23 11:03:23 +08:00
Bingxi Zhao (Frank)
ad958a5cd7 fix(textbook): retain shared boundary pages in chapter spans 2026-09-23 10:44:09 +08:00
Bingxi Zhao (Frank)
c323516312 fix(textbook): expose header rebuild and preserve final page range 2026-09-23 10:38:16 +08:00
interia
4a01a8cffc feat(textbook): rebuild chapters from running headers embedded mid-text
Some publishers print the chapter name embedded mid-text in the running
header (e.g. "集合第1章", "空间向量与立体几何 第6章"), often without a
leading "第", while the footer only carries the publisher name — a
footer-only pass then finds zero chapters.

page_facts() now reads chapter-shaped furniture from both positions:
footer blocks matching CHAPTER_RE verbatim, and header blocks whose
chapter token sits mid-text, extracted via HEADER_CHAPTER_RE and
normalized to the canonical "第N章 章名" shape by
normalize_header_chapter() (bare token / name-before-token /
name-after-token forms; book titles, token-less headers and long prose
are rejected as boundaries). Both channels share the existing level
filter and seen-dedupe; the printed-page offset check verifies boundary
correctness end to end. Covered by 9 new tests including two-level
running-header unit filtering and offset constancy.
2026-09-11 13:30:58 +08:00