fix: correct section page ranges at page-leading headings - #21
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Root cause
extract_raw_sections()advanced the current section'spage_endbefore 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()andprimary_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
Introduction.page_end == 2instead of1python -m pytest -q tests/test_extract_source_text.py—6 passedpython -m ruff check --no-cache --select F,I skills/deeppapernote/scripts/extract_source_text.py tests/test_extract_source_text.py— passedpython -m compileall -q skills/deeppapernote/scripts— passedpython -m pytest -q—827 passed, 1 skippedScope
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.