chore: organize scripts

This commit is contained in:
2026-06-17 00:03:04 +00:00
parent 406641c522
commit 0ba87ac547

17
scripts/pages.py Normal file
View File

@@ -0,0 +1,17 @@
import pathlib
import re
PAGE_RGX = r"page ([0-9]+)"
# for root, dirs, files in pathlib.Path("./books/core").walk():
for root, dirs, files in pathlib.Path("./books/natural-fantasy-atlas").walk():
files = [root / fn for fn in files if fn.endswith(".html")]
for fn in files:
with fn.open() as fh:
html = fh.read()
with fn.open('w') as fh:
for line in html.split("\n"):
if re.search(PAGE_RGX, line) and "</a" not in line:
line = re.sub(PAGE_RGX, r'<a href="/books/natural-fantasy-atlas/#page-\1">\g<0></a>', line)
fh.write(line)