Replace 3+ consecutive blank lines with 2.
(content: str)
| 427 | # ── collapse excess blank lines ─────────────────────────────────────────────── |
| 428 | |
| 429 | def collapse_blank_lines(content: str) -> str: |
| 430 | """Replace 3+ consecutive blank lines with 2.""" |
| 431 | return re.sub(r'\n{4,}', '\n\n\n', content) |
| 432 | |
| 433 | |
| 434 | # ── repeated header/footer and cover image cleanup ─────────────────────────── |