make-pdf: --compact, for documents that are not scenarios

One section per page is right for a scenario, where a GM turns to a section
and reads it. A four-page update note printed eight pages with a paragraph
on each. --compact keeps the section rules and drops the page break.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
slaguru666
2026-09-30 19:13:49 +01:00
co-authored by Claude Opus 5
parent f892793b96
commit 0330a537f0
2 changed files with 8 additions and 2 deletions
Binary file not shown.
+8 -2
View File
@@ -13,6 +13,10 @@
* headless print is a real renderer with real page rules, so that is the engine.
*
* node tools/make-pdf.mjs docs/scenarios/STANDING_ORDER.md [--out <path.pdf>] [--keep-html]
*
* --compact drops the page break before each section. A scenario wants one section per page,
* because a GM turns to a section and reads it; a two-page update note does not, and giving
* it one printed eight pages with a paragraph on each.
*/
import { readFileSync, readdirSync, writeFileSync, existsSync, mkdirSync } from "node:fs";
import { execFileSync } from "node:child_process";
@@ -22,6 +26,7 @@ const ROOT = path.resolve(path.dirname(new URL(import.meta.url).pathname.replace
const argv = process.argv.slice(2);
const SRC = argv.find(a => !a.startsWith("--"));
if (!SRC) { console.error("usage: node tools/make-pdf.mjs <scenario.md> [--out file.pdf]"); process.exit(1); }
const COMPACT = argv.includes("--compact");
const outArg = argv.indexOf("--out");
const OUT = path.resolve(ROOT, outArg > -1 ? argv[outArg + 1]
: path.join("docs", "print", path.basename(SRC).replace(/\.md$/, ".pdf")));
@@ -147,8 +152,9 @@ body { margin: 0; line-height: 1.45; }
h1, h2, h3, h4 { font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; line-height: 1.2; }
h1 { display: none; } /* the cover carries the title */
h2 { font-size: 15pt; letter-spacing: .04em; text-transform: uppercase;
border-bottom: 2pt solid #7a1f1f; padding-bottom: 2mm; margin: 0 0 4mm;
break-before: page; break-after: avoid; }
border-bottom: 2pt solid #7a1f1f; padding-bottom: 2mm; margin: ${COMPACT ? "7mm 0 4mm" : "0 0 4mm"};
${COMPACT ? "" : "break-before: page;"} break-after: avoid; }
h2:first-of-type { margin-top: 0; }
h3 { font-size: 12pt; margin: 6mm 0 2mm; break-after: avoid; }
h4 { font-size: 10.5pt; margin: 4mm 0 1mm; break-after: avoid; }
p { margin: 0 0 2.4mm; orphans: 3; widows: 3; }