Scripts to probe a book's TOC, print each page-level item to PDF via the print popup, verify, merge per 대항목 and clean up temp files. Invoked only by /lawnb-pdf-download (disable-model-invocation). Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
20 lines
730 B
Python
20 lines
730 B
Python
#!/usr/bin/env python3
|
|
"""Inject a JSON config into a script template and write the result.
|
|
|
|
ego-browser scripts do not inherit environment variables or argv, so every
|
|
input has to be written into the script text. This helper replaces the
|
|
literal token __CFG__ in a template with the JSON config.
|
|
|
|
Usage:
|
|
python3 render.py <template.js> <config.json> <output.js>
|
|
"""
|
|
import json
|
|
import sys
|
|
|
|
template, cfg_path, out_path = sys.argv[1:4]
|
|
cfg = json.load(open(cfg_path, encoding="utf-8"))
|
|
src = open(template, encoding="utf-8").read()
|
|
assert "__CFG__" in src, "template has no __CFG__ placeholder"
|
|
open(out_path, "w", encoding="utf-8").write(src.replace("__CFG__", json.dumps(cfg, ensure_ascii=False)))
|
|
print("rendered", out_path)
|