Skip to content

feat: add edge-case supplement pages to test PDF (sections 10-13) - #4

Closed
MatMatt wants to merge 5 commits into
developfrom
feat/test-pdf-supplement
Closed

feat: add edge-case supplement pages to test PDF (sections 10-13)#4
MatMatt wants to merge 5 commits into
developfrom
feat/test-pdf-supplement

Conversation

@MatMatt

@MatMatt MatMatt commented Jul 26, 2026

Copy link
Copy Markdown
Collaborator

Summary

Appends 3 new pages (sections 10-13) to pdf2md_edgecases.pdf, covering 6 edge cases the original 11-page PDF didn't test.

Also adds a maintainable generator at tests/gen_edgecase_supplement.py — run from repo root to regenerate.

What's added

§ Coverage Why
10 Clickable hyperlink annotations — 4 real PDF link annotations (web, email, repo, DOI) Tests link recovery from PDF annotations (commit e29d0b1)
11 \DATA / <sub> / <sup> / <br> raw patterns Tests _sanitise_for_typst() Phase 2.5c
12 130249 display math (Einstein equations) + ambiguous notation (error bars, set notation, stats) Tests math detection tightening + math-skip in sanitiser (cd5e9b9)
13 Chrome variants per page ("Introduction"/"Methods"/"Results" headers) Tests chrome.py per-page variant detection
13 "Page N of 3" footer pattern Tests lint.py chrome-leak guard
13 Nested image paths + doubled URL schemes Tests lint.py "File name too long" guard

Verification

All 9 checks pass:

Total pages: 14
  [OK] 1. Hyperlink annotations
  [OK] 2. \DATA pattern
  [OK] 3. HTML <sub>/<sup>/<br>
  [OK] 4. 130249 display math
  [OK] 5. Ambiguous notation
  [OK] 6. Chrome variants
  [OK] 7. Page-N-of-M footer
  [OK] 8. Nested image paths
  [OK] 9. Doubled URL schemes

How to regenerate

pip install fpdf2 pypdf
python3 src/pdf2md/tests/gen_edgecase_supplement.py

The original 11-page PDF is preserved — only the supplement is rebuilt and merged.

@MatMatt — tagging you for review

MatMatt added 5 commits July 26, 2026 10:08
Append 3 new pages (sections 10-13) to pdf2md_edgecases.pdf
covering 6 previously untested scenarios:

- Clickable hyperlink annotations (PDF link annotations)
- \DATA / <sub> / <sup> / <br> raw patterns (_sanitise_for_typst)
- 130171 display math + ambiguous notation (math false-positive guards)
- Running header variants per page (chrome.py detection)
- Page-N-of-M footer pattern (lint.py chrome-leak guard)
- Nested image paths + doubled URL schemes (lint.py)

Regeneration: python3 src/pdf2md/tests/gen_edgecase_supplement.py
Remove 1990-2018_PUM_v1_short.pdf (real CLMS PUM snippet) and
port the 2 pagefilter regression tests to pdf2md_edgecases.pdf.

The synthetic edgecases PDF covers both scenarios:
- recall: pages 9 (aerial photo raster) and 11 (vector figure) detected
- skip rate: 7 text-only pages correctly skipped
- --main-llm <slug> replaces --model (--model kept as deprecated alias)
- --figure-llm <slug> for Phase 1 figure detection
- pdf2md --setup now fetches model catalogue from OpenRouter API
  and presents a numbered pick list (multimodal first, sorted by price)
  for both conversion LLM and figure-detection LLM
- Config saved to ~/.pdf2md/config.json under 'model' and 'figure_llm'
@MatMatt

MatMatt commented Jul 26, 2026

Copy link
Copy Markdown
Collaborator Author

Merged into feat/review-module (PR #3) — all changes now in one branch

@MatMatt MatMatt closed this Jul 26, 2026
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