Skip to content

Commit d850f14

Browse files
claude: Use idiomatic pdfstandard map structure for templates
Refactor PDF standard template variables to use Pandoc's idiomatic pattern of a single map variable with dot notation access: - pdfstandard.standards - list of PDF standards - pdfstandard.version - PDF version string - pdfstandard.tagging - boolean for tagging requirement This replaces the previous separate variables (pdfstandard, pdfstandards, pdfversion, pdftagging) and aligns with how Pandoc handles similar cases like bibliography and date metadata. Also adds lang to DocumentMetadata and skips pdflang in hypersetup when pdfstandard is set to avoid duplication. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 41e6b6c commit d850f14

3 files changed

Lines changed: 32 additions & 19 deletions

File tree

‎src/format/pdf/format-pdf.ts‎

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -330,18 +330,20 @@ function createPdfFormat(
330330
if (pdfStandard.length > 0) {
331331
const { version, standards, needsTagging } =
332332
normalizePdfStandardForLatex(pdfStandard);
333-
extras.pandoc.variables = extras.pandoc.variables || {};
334-
extras.pandoc.variables["pdf-standard"] = true; // Enable the partial
335-
if (version) {
336-
extras.pandoc.variables["pdf-version"] = version;
337-
}
338-
if (standards.length > 0) {
339-
// Pass as array - Pandoc template will iterate with $for()$
340-
extras.pandoc.variables["pdf-standards"] = standards;
341-
}
342-
// Enable tagging only for standards that require it (ua-*, a-*a)
343-
if (needsTagging) {
344-
extras.pandoc.variables["pdf-tagging"] = true;
333+
// Set pdfstandard as a map if there are standards or a version
334+
if (standards.length > 0 || version) {
335+
extras.pandoc.variables = extras.pandoc.variables || {};
336+
const pdfstandardMap: Record<string, unknown> = {};
337+
if (standards.length > 0) {
338+
pdfstandardMap.standards = standards;
339+
}
340+
if (version) {
341+
pdfstandardMap.version = version;
342+
}
343+
if (needsTagging) {
344+
pdfstandardMap.tagging = true;
345+
}
346+
extras.pandoc.variables["pdfstandard"] = pdfstandardMap;
345347
}
346348
}
347349

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,20 @@
1-
$if(pdf-standard)$
1+
$--
2+
$-- PDF standard support (PDF/A, PDF/UA, PDF/X)
3+
$-- Requires LuaLaTeX and recent LaTeX (2023+)
4+
$--
5+
$if(pdfstandard)$
26
\DocumentMetadata{
3-
$if(pdf-version)$
4-
pdfversion=$pdf-version$,
7+
$if(pdfstandard.version)$
8+
pdfversion=$pdfstandard.version$,
59
$endif$
6-
$if(pdf-standards)$
7-
pdfstandard={$for(pdf-standards)$$it$$sep$,$endfor$},
10+
$if(pdfstandard.standards)$
11+
pdfstandard={$for(pdfstandard.standards)$$it$$sep$,$endfor$},
812
$endif$
9-
$if(pdf-tagging)$
13+
$if(pdfstandard.tagging)$
1014
tagging=on,
1115
$endif$
12-
}
16+
$if(lang)$
17+
lang=$lang$,
18+
$endif$
19+
xmp=true}
1320
$endif$

‎src/resources/formats/pdf/pandoc/hypersetup.latex‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,12 @@ $if(author-meta)$
66
pdfauthor={$author-meta$},
77
$endif$
88
$if(lang)$
9+
$if(pdfstandard)$
10+
$-- lang is set in DocumentMetadata instead
11+
$else$
912
pdflang={$lang$},
1013
$endif$
14+
$endif$
1115
$if(subject)$
1216
pdfsubject={$subject$},
1317
$endif$

0 commit comments

Comments
 (0)