""" Render every summaries/**/*.md to a sibling .html — mobile-readable (viewport meta + real font size), served alongside the .md via `tailscale serve`. Also (re)writes summaries/index.html linking every rendered page. Run after adding/editing any summary. """ from pathlib import Path import markdown ROOT = Path(__file__).parent / "summaries" PAGE_TEMPLATE = """ {title} {body} """ def render_file(md_path: Path) -> Path: text = md_path.read_text(encoding="utf-8") body = markdown.markdown(text, extensions=["extra"]) title = text.splitlines()[0].lstrip("# ").strip() if text else md_path.stem html_path = md_path.with_suffix(".html") html_path.write_text(PAGE_TEMPLATE.format(title=title, body=body), encoding="utf-8") return html_path def write_index(pages: list[Path]): items = "\n".join( f'
  • {p.parent.name} / {p.stem}
  • ' for p in sorted(pages) ) (ROOT / "index.html").write_text( PAGE_TEMPLATE.format(title="ATM — Sumarizări", body=f"

    ATM — Sumarizări

    "), encoding="utf-8", ) def main(): md_files = sorted(ROOT.glob("*/*.md")) pages = [render_file(f) for f in md_files] write_index(pages) print(f"Rendered {len(pages)} page(s) + index.html") if __name__ == "__main__": main()