(path: Path, dry_run: bool)
| 699 | # ── main processing ─────────────────────────────────────────────────────────── |
| 700 | |
| 701 | def process_file(path: Path, dry_run: bool) -> dict: |
| 702 | original = path.read_text(encoding='utf-8') |
| 703 | content = original |
| 704 | |
| 705 | content, toc_removed = remove_toc_tables(content) |
| 706 | content, fn_count = reformat_footnotes(content) |
| 707 | content, frag_merged = merge_fragmented_tables(content) |
| 708 | content, dup_cols_fixed = deduplicate_table_columns(content) |
| 709 | content = deduplicate_headers(content) |
| 710 | |
| 711 | content, hdr_removed = cleanup_page_headers_and_cover_images(content) |
| 712 | content, lay_fixed = fix_complex_layouts(content) |
| 713 | content, specific_fixed = apply_specific_fixes(content) |
| 714 | content, bullets_fixed = fix_messy_bullets(content) |
| 715 | content, paras_joined = join_split_paragraphs(content) |
| 716 | |
| 717 | content = collapse_blank_lines(content) |
| 718 | |
| 719 | changed = content != original |
| 720 | stats = { |
| 721 | 'toc_removed': toc_removed, |
| 722 | 'footnotes': fn_count, |
| 723 | 'frag_merged': frag_merged, |
| 724 | 'dup_cols_fixed': dup_cols_fixed, |
| 725 | 'hdr_removed': hdr_removed, |
| 726 | 'lay_fixed': lay_fixed, |
| 727 | 'specific_fixed': specific_fixed, |
| 728 | 'bullets_fixed': bullets_fixed, |
| 729 | 'paras_joined': paras_joined, |
| 730 | 'changed': changed, |
| 731 | } |
| 732 | |
| 733 | if changed and not dry_run: |
| 734 | path.write_text(content, encoding='utf-8') |
| 735 | |
| 736 | return stats |
| 737 | |
| 738 | |
| 739 | def main(): |
no test coverage detected