Files
luuuyi 9516a811c6 fix(render): silent no-op writes, and all undercounting slides by 20% (#37)
Two independent defects, both of which hand the user a wrong artefact while
reporting success.

1. `render.sh deck.html 3 out/png` wrote nothing and still printed three ✔.
   `mkdir -p "$OUT"` only ran in the branch that *derives* an output directory,
   so an explicitly-passed directory was never created. Chrome exits 0 when it
   cannot write the screenshot, and `render_one()`'s ✔ was unconditional — the
   run ended with "done: rendered 3 slide(s)" and zero files on disk.

2. `render.sh deck.html all` under-rendered 13 of the 15 bundled decks.
   `grep -c 'class="slide"'` is an exact-string match, but real slides carry
   extra classes (`slide is-active`, `slide dark`, `slide t-violet`). Across
   templates/full-decks that counted 95 of 119 slides; dir-key-nav-minimal
   counted 0, fell through to the `COUNT=1` fallback, and exported a single PNG
   for an 8-slide deck without a warning.

Changes:
- create the output directory on every path that has one (accepting either a
  directory, as documented, or an explicit *.png file path)
- verify each screenshot exists and is non-empty before printing ✔; otherwise
  print ✗ to stderr and exit non-zero
- count slides by matching `slide` as a whole class token on `<section>`,
  which yields 119/119 and does not match `class="slide-number"`
- warn on stderr when the fallback count of 1 is used
- single-slide renders with an out-dir now write <out-dir>/<stem>.png instead
  of treating the directory as the file name
- reject a non-numeric slide count instead of passing it to seq

Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
2026-09-14 15:36:23 +08:00
..