(
pdf_path: Path,
appendix_start_page: int | None,
)
| 1808 | |
| 1809 | |
| 1810 | def extract_appendix_page_texts( |
| 1811 | pdf_path: Path, |
| 1812 | appendix_start_page: int | None, |
| 1813 | ) -> list[dict[str, Any]]: |
| 1814 | if fitz is None or not pdf_path.is_file() or not appendix_start_page: |
| 1815 | return [] |
| 1816 | |
| 1817 | try: |
| 1818 | doc = fitz.open(pdf_path) |
| 1819 | except Exception: |
| 1820 | return [] |
| 1821 | |
| 1822 | pages: list[dict[str, Any]] = [] |
| 1823 | try: |
| 1824 | start_index = max(int(appendix_start_page) - 1, 0) |
| 1825 | for page_index in range(start_index, len(doc)): |
| 1826 | text = doc[page_index].get_text("text") |
| 1827 | cleaned = normalize_whitespace(text) |
| 1828 | if cleaned: |
| 1829 | pages.append({"page": page_index + 1, "text": text}) |
| 1830 | finally: |
| 1831 | doc.close() |
| 1832 | return pages |
| 1833 | |
| 1834 | |
| 1835 | def appendix_section_title(line: str) -> str: |
no test coverage detected