Skip to content

fix: correct section page ranges at page-leading headings - #21

Merged
917Dhj merged 1 commit into
917Dhj:mainfrom
KumamuKuma:fix/page-leading-section-ranges
Aug 2, 2026
Merged

fix: correct section page ranges at page-leading headings#21
917Dhj merged 1 commit into
917Dhj:mainfrom
KumamuKuma:fix/page-leading-section-ranges

Conversation

@KumamuKuma

Copy link
Copy Markdown
Contributor

Summary

  • close the previous section on the preceding page when a new page starts with a recognized section heading
  • preserve overlapping page coverage when the heading appears after section content on the same page
  • add focused regressions for page-leading and mid-page headings

Root cause

extract_raw_sections() advanced the current section's page_end before examining the first meaningful line on each page. When that line was a new section heading, the previous section was therefore recorded as covering the new section's page as well.

This caused section_ids_for_page() and primary_section_for_page() to expose the previous section on a page that begins with a new heading, which could bind captions on that page to the wrong section.

Validation

  • before the fix, the page-leading regression failed with Introduction.page_end == 2 instead of 1
  • python -m pytest -q tests/test_extract_source_text.py6 passed
  • python -m ruff check --no-cache --select F,I skills/deeppapernote/scripts/extract_source_text.py tests/test_extract_source_text.py — passed
  • python -m compileall -q skills/deeppapernote/scripts — passed
  • python -m pytest -q827 passed, 1 skipped
  • independent diff review found no blocking issues

Scope

This remains page-granular by design. It does not change caption attribution for captions after a mid-page heading, which would require line-position-aware parsing.

@917Dhj
917Dhj merged commit 917a609 into 917Dhj:main Aug 2, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants