修正预印红头留白并严格校验参数

This commit is contained in:
mizzlelover
2026-09-11 08:30:00 +08:00
parent 4bf5d00346
commit 6b9d19698f
35 changed files with 41 additions and 3 deletions
+13
View File
@@ -826,6 +826,10 @@ function buildDocument(blocks, args) {
// separator. Its reserve is a paper-coordinate boundary, so optional
// copy/secret/urgency fields must not shorten it.
body.push(letterheadReserveParagraph(reserve));
// The preprinted paper supplies the agency mark and separator. Keep the
// variable document number below the reserved mark block by preserving
// the same two 28-point grid lines used under a digital agency mark.
if (args["doc-no"]) body.push(...blankGridLines(2));
}
if (args["doc-no"]) args["doc-no"] = normalizeDocumentNumber(args["doc-no"]);
if (upward && args["doc-no"] && args.signer) body.push(upwardHeaderParagraph(args["doc-no"], args.signer));
@@ -1045,6 +1049,15 @@ if (args.help || !args.input || !args.output) {
usage();
process.exit(args.help ? 0 : 1);
}
const supportedFormats = ["ordinary", "formal", "letter", "command", "minutes", "horizontal-table"];
try {
if (args.format !== undefined && !supportedFormats.includes(args.format)) throw new Error(`--format must be one of ${supportedFormats.join(", ")}`);
if (args.letterhead !== undefined && !["preprinted", "digital"].includes(args.letterhead)) throw new Error("--letterhead must be preprinted or digital");
if (args["page-number"] !== undefined && !["center", "standard", "none"].includes(args["page-number"])) throw new Error("--page-number must be center, standard, or none");
} catch (error) {
console.error(`GENERATOR ERROR: ${error.message}`);
process.exit(2);
}
try {
reportFontStatus(args);
} catch (error) {
+3
View File
@@ -170,6 +170,9 @@ if (profile === "formal") {
const titleXmlStart = firstTitleIndex < 0 ? doc.length : doc.indexOf(preprintedParagraphs[firstTitleIndex]);
const preprintedHeaderXml = titleXmlStart < 0 ? doc : doc.slice(0, titleXmlStart);
check("No red drawing for preprinted letterhead", !/w:color w:val="FF0000"/.test(preprintedHeaderXml), "preprinted mode does not redraw red letterhead or rule");
const preprintedDocNoIndex = preprintedParagraphs.findIndex((p) => /\d{4}[1-9]\d*/.test(textOf(p)));
const preprintedDocNoGap = preprintedDocNoIndex >= 0 ? preprintedParagraphs.slice(0, preprintedDocNoIndex).slice(-2) : [];
check("Preprinted agency-to-document number two blank lines", preprintedDocNoIndex < 0 || (preprintedDocNoGap.length === 2 && preprintedDocNoGap.every(isExplicitBlankGridLine)), "document number starts below the reserved physical agency mark block");
check("Title spacing below physical red rule", hasExplicitTwoLineTitleGap, "title is preceded by two exact 28-point blank paragraphs below the printed red rule");
}
}