Files
fabula-ultima-html/scripts/add_css.py
2026-06-06 13:03:00 +00:00

23 lines
681 B
Python

#!/usr/bin/env python3
"""Prepend a book-page.css link to every HTML file in html2/."""
from pathlib import Path
CSS_LINK = '<link rel="stylesheet" href="book-page.css">\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()