Parse-only primitive: cuts a Markdown body at every ATX heading of a
chosen level, returns a flat list[Section] sized for
one-chunk-per-LLM-call pipeline consumption. Strict contract — NO
heuristics in upstream (is_single_book_bian, merge_tiny_items,
strip_trailing_next_title all stay downstream). Next same-or-higher
heading ends a section (# ends ## section, ### stays inside); fences
skipped; CommonMark §4.2 0-3 space indent tolerated; preface before
first match not returned (downstream takes body[:sections[0].start]).
Reuses sections._iter_headings for fence-aware heading iteration —
no regex duplication. 27 tests covering preface slicing, fenced
pseudo-headings, 0-3 / 4+ indent, CRLF, CR-only (classic Mac —
Codex MEDIUM round 1 fix), levels 1/3/6, realistic 太虛 編/章/甲乙.
Reviewed by Codex: LGTM after 1 round of fixes.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>