"""Render public Markdown originals to static HTML; --check detects stale pages.""" import argparse import html import re from pathlib import Path import markdown2 ROOT = Path(__file__).resolve().parents[1] PAGES = {'INSTALL.md': 'install.html', 'RELEASE_NOTES.md': 'release-notes.html', 'THIRD_PARTY_NOTICES.md': 'licenses.html', 'LICENSE': 'license.html', 'BENCHMARKS.md': 'benchmarks.html', 'CONNECTORS.md': 'connectors.html', 'docs/legal/PUBLIC_SCOPE.md': 'legal-scope.html'} def render(name): source = (ROOT/name).read_text(encoding='utf-8') # Strip fence language hints so optional Pygments cannot change generated bytes. source = re.sub(r'^```[^\n]+$', '```', source, flags=re.MULTILINE) title = source.splitlines()[0].lstrip('# ').strip() if name != 'LICENSE' else 'Application license — AGPL-3.0-only' body = '
'+html.escape(source)+'' if name == 'LICENSE' else markdown2.markdown(source, extras=['fenced-code-blocks', 'tables'], safe_mode='escape') for old, new in PAGES.items(): body = body.replace('href="'+old+'"', 'href="'+new+'"') return ('\n' '