feat: Add core rules
This commit is contained in:
22
scripts/add_css.py
Normal file
22
scripts/add_css.py
Normal file
@@ -0,0 +1,22 @@
|
||||
#!/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()
|
||||
Reference in New Issue
Block a user