Skip to content

feat: scope page ranges to match and fields - #754

Open
pjkersten wants to merge 1 commit into
invoice-x:masterfrom
pjkersten:feat/selector-scoped-pages
Open

feat: scope page ranges to match and fields#754
pjkersten wants to merge 1 commit into
invoice-x:masterfrom
pjkersten:feat/selector-scoped-pages

Conversation

@pjkersten

Copy link
Copy Markdown
Contributor

Templates for envelope-style PDFs need to match identifying text on one page while extracting invoice fields and line items from other pages.

This adds an explicit match: selector with its own pages, keywords, and exclude_keywords, plus field-local pages support for modern fields: parsers, including fields.lines.

  • match.pages scopes only template selection.
  • fields.<name>.pages scopes only that field's input text.
  • A field's area intersects its own page scope.
  • Legacy top-level pages remains supported as a homogeneous-template compatibility shortcut.
  • Mixing the explicit selector with legacy keywords, exclude_keywords, or pages is rejected to avoid ambiguous scope.

Documentation includes an envelope + invoice recipe. Regression coverage tests matching on page 1, scalar extraction from pages 1 and 2–3, and modern lines extraction from pages 2–3.

Tests: pytest — 1198 passed, 6 skipped.

@github-actions

Copy link
Copy Markdown

Coverage report

Click to see where and how coverage changed

FileStatementsMissingCoverageCoverage
(new stmts)
Lines missing
  src/invoice2data
  api.py
  src/invoice2data/extract
  invoice_template.py
  loader.py 226-230, 239-243, 249
  tests
  test_page_ranges.py
Project Total  

This report was generated by python-coverage-comment-action

@pjkersten
pjkersten marked this pull request as ready for review August 24, 2026 09:24
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.

1 participant