"""Parse-check every ``", head, re.S) def main() -> int: try: from playwright.sync_api import sync_playwright except ImportError: print("playwright is not installed; skipping the head-script parse check") return 0 scripts = head_scripts() failures = 0 with sync_playwright() as pw: executable = os.environ.get("CHROMIUM_EXECUTABLE") or None try: browser = pw.chromium.launch(executable_path=executable) except Exception as err: # noqa: BLE001 - any launch failure means "no browser here" print(f"no chromium available ({type(err).__name__}); skipping the parse check") return 0 page = browser.new_page() page.goto("about:blank") for index, source in enumerate(scripts): result = page.evaluate( "(src) => { try { new Function(src); return 'ok'; } catch (e) { return e.message; } }", source, ) print(f"script block {index} ({len(source)} chars): {result}") failures += result != "ok" browser.close() return 1 if failures else 0 if __name__ == "__main__": sys.exit(main())