Split by bookmarks: 9 chapters, 10/10, one bug caught
The numbers first: 10 bookmarks in, naive per-bookmark splitting produced 12 overlapping chapters, the fixed boundary rule produced 9 chapters, 10/10 bookmarks verified. This run closes the loop between our merge offset formula and the split filter-and-minus rule: split a merged document by its own bookmarks, one chapter per bookmark, and check every destination.
The bug we hit first
All 10 bookmarks sat at level 1, so a naive “one chapter per bookmark” rule created overlapping chapters: A s3 and A s4 both target page 3, and both claimed pages 3… (12 bookmarks written across 10 chapters). A split with overlaps is not a split.
The fixed rule
A new chapter starts only at a bookmark whose destination page is strictly greater than the previous chapter’s start. Bookmarks sharing a page belong to the current chapter. Boundary: chapter end = next chapter start − 1 (last chapter runs to the final page).
The executed result
- 9 chapters from pages 1–9, no overlaps, no gaps.
- Chapter 3 (
A s3) carries 2 bookmarks on its single page — correct, they share it. - Every chapter’s bookmark remapped with
page’ = page − start + 1and verified: target page text inside the chapter equals the source page text — 10/10 True, all 9 chapters.
Decision rule this run supports
Bookmark-driven splitting is safe only when the boundary rule deduplicates same-page bookmarks. With that rule, per-chapter bookmark counts sum exactly to the source outline — a check any tool can show instead of claiming “bookmarks preserved”.