(record: dict[str, Any])
| 121 | |
| 122 | |
| 123 | def finalize_section(record: dict[str, Any]) -> dict[str, Any] | None: |
| 124 | lines = [line for line in record.pop("_lines", []) if normalize_whitespace(str(line))] |
| 125 | text = "\n".join(lines).strip() |
| 126 | if not text: |
| 127 | return None |
| 128 | record["text"] = text |
| 129 | record["char_count"] = len(text) |
| 130 | record["text_hash_sha256"] = text_hash(text) |
| 131 | return record |
| 132 | |
| 133 | |
| 134 | def extract_page_texts(pdf_path: Path, max_pages: int | None) -> list[dict[str, Any]]: |
no test coverage detected