| 1 | #!/usr/bin/env python3 |
| 2 | """Reformat completed scraped documents without shortening their content.""" |
| 3 | |
| 4 | from pathlib import Path |
| 5 | import re |
| 6 | |
| 7 | from scrape_bookmarks import clean_markdown |
| 8 | |
| 9 | |
| 10 | ROOT = Path(__file__).resolve().parent |
| 11 | OUTPUT = ROOT / "property-pages" |
| 12 | |
| 13 | |
| 14 | for path in sorted(OUTPUT.glob("*.md")): |
| 15 | original = path.read_text(encoding="utf-8") |
| 16 | heading = re.search(r"^#\s+(.+)$", original, flags=re.M) |
| 17 | title = heading.group(1).strip() if heading else path.stem |
| 18 | path.write_text(clean_markdown(original, title), encoding="utf-8") |
| 19 | print(path.name) |