| 263 | |
| 264 | |
| 265 | def write_full_text_markdown(records: list[dict[str, Any]], output_path: str, title: str) -> None: |
| 266 | ensure_parent(output_path) |
| 267 | lines = [f"# {title or 'Full Source Text'}", ""] |
| 268 | for record in records: |
| 269 | lines.extend( |
| 270 | [ |
| 271 | f"## {record.get('section_id', '')} {record.get('title', '')}".strip(), |
| 272 | f"_Pages {record.get('page_start')}-{record.get('page_end')}_", |
| 273 | "", |
| 274 | str(record.get("text", "")).strip(), |
| 275 | "", |
| 276 | ] |
| 277 | ) |
| 278 | Path(output_path).expanduser().resolve().write_text( |
| 279 | "\n".join(lines).rstrip() + "\n", |
| 280 | encoding="utf-8", |
| 281 | ) |
| 282 | |
| 283 | |
| 284 | def build_manifest( |