"""Shared helpers for the trpgphysics.org build scripts (loaded by path, because `python -I` does not put the script folder on sys.path). Header/footer text is copied exactly from the existing pages.""" import html, pathlib, re NAV_ITEMS = [ ("index.html", "Home"), ("theory.html", "The theory"), ("equation.html", "Equation"), ("results.html", "Results"), ("paper.html", "Paper"), ("record.html", "Record"), ("data.html", "Data & code"), ("credits.html", "Credits"), ("publications.html", "Publications"), ("math.html", "The math"), ("code.html", "The code"), ("originals.html", "Who did the math first"), ("about.html", "About"), ] COPY = "© 2026 Matthew Gelfman and Melissa Gelfman" FOOTER = ('\n') def nav_html(current, available): parts = [] for href, label in NAV_ITEMS: if href not in available: continue cur = ' aria-current="page"' if href == current else "" parts.append(f'{label}') return '" def page(fname, title, desc, body, available): d = html.escape(desc, quote=True) t = html.escape(title) return f'''