#!/usr/bin/env python3 """Prepend a book-page.css link to every HTML file in html2/.""" from pathlib import Path CSS_LINK = '\n' HTML2_DIR = Path(__file__).parent.parent / "html2" def main(): files = sorted(HTML2_DIR.glob("*.html"), key=lambda p: int(p.stem) if p.stem.isdigit() else -1) for path in files: content = path.read_text(encoding="utf-8") if CSS_LINK.strip() not in content: path.write_text(CSS_LINK + content, encoding="utf-8") print(f"updated {path.name}") else: print(f"skipped {path.name} (already has link)") if __name__ == "__main__": main()