Files
Eric WagonerandClaude Fable 5.2 f2bb87caeb Credibility pass over the Green Man generator
Turn audit.py into a run() function and drop audit_run.py, which only
existed to import it quietly. Remove unused parameters, keys, helpers
and imports from draw.py, manifest.py and stl_build.py, and the source
file names in stl_build.FILES that pointed at nothing. Keep the brow
strip's taper and knob positions in geom.py only. Correct comments and
docstrings that disagreed with the code, and the README's claim about
counts.

The page changes only in markup: no stray spaces in class attributes,
and three CSS declarations that did nothing are gone. Guide HTML,
templates and print files are byte-identical apart from that.

Credibility pass over a7c04e5..HEAD; the next one can scope from here.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-10 19:14:03 -05:00

23 lines
1.4 KiB
Python

"""Render an HTML file to PNG (for checking) or PDF (for the kit) with Playwright's Chromium, or Google Chrome if Playwright has no browser of its own."""
import sys, asyncio
from playwright.async_api import async_playwright
async def go(src, out, width=1260, footer=None):
async with async_playwright() as p:
try: b = await p.chromium.launch()
except Exception: b = await p.chromium.launch(channel='chrome') # no Playwright browser installed: use Google Chrome
pg = await b.new_page(viewport={'width': width, 'height': 800})
await pg.goto('file://' + src); await pg.evaluate('document.fonts.ready'); await pg.wait_for_timeout(300)
if out.endswith('.pdf'):
kw = dict(display_header_footer=True, header_template='<span></span>', footer_template=
'<div style="font-family:Inter,Helvetica,sans-serif;font-size:7.5px;color:#777;width:100%;padding:0 14mm;display:flex;justify-content:space-between"><span>' + footer +
'</span><span><span class="pageNumber"></span> / <span class="totalPages"></span></span></div>') if footer else {}
await pg.pdf(path=out, prefer_css_page_size=True, print_background=True, **kw)
else:
await pg.screenshot(path=out, full_page=True)
await b.close()
if __name__ == '__main__':
src, out = sys.argv[1], sys.argv[2]
asyncio.run(go(src, out, width=int(sys.argv[3]) if len(sys.argv) > 3 else 1260))