Skip to content

Commit ce0ea9a

Browse files
claude: Filter unsupported PDF standards from verapdf validation
When LaTeX doesn't support a PDF standard (e.g., ua-1), it warns and ignores it. Previously, verapdf would still try to validate against the unsupported standard, causing spurious failures. Now the applied standards are stored in metadata during format extras and used for validation, so only standards that were actually applied get validated. Changes: - Add kPdfStandardApplied constant for filtered standards - Store applied standards in extras.metadata during format processing - Read from pandocOptions.format.metadata for validation - Add latex-ua1-filtered.qmd test for filtering behavior - Update latex-multi-standard.qmd to use a-4f + ua-2 (compatible) - Update latex-combined.qmd to use 1.7 + a-2b (simpler test) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent e3fb091 commit ce0ea9a

6 files changed

Lines changed: 68 additions & 8 deletions

File tree

‎src/command/render/output-tex.ts‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import {
1616
kOutputExt,
1717
kOutputFile,
1818
kPdfStandard,
19+
kPdfStandardApplied,
1920
kTargetFormat,
2021
} from "../../config/constants.ts";
2122
import { Format } from "../../config/types.ts";
@@ -83,9 +84,13 @@ export function texToPdfOutputRecipe(
8384
const input = join(inputDir, output);
8485
const pdfOutput = await pdfGenerator.generate(input, format, pandocOptions);
8586

86-
// Validate PDF against specified standards using verapdf (if available)
87+
// Validate PDF against applied standards using verapdf (if available)
88+
// Use kPdfStandardApplied from pandocOptions.format.metadata (filtered by LaTeX support)
89+
// if available, otherwise fall back to original kPdfStandard list
8790
const pdfStandards = asArray(
88-
format.render?.[kPdfStandard] ?? format.metadata?.[kPdfStandard],
91+
pandocOptions.format.metadata?.[kPdfStandardApplied] ??
92+
format.render?.[kPdfStandard] ??
93+
format.metadata?.[kPdfStandard],
8994
) as string[];
9095
if (pdfStandards.length > 0) {
9196
await validatePdfStandards(pdfOutput, pdfStandards, {

‎src/config/constants.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ export const kKeepMd = "keep-md";
8787
export const kKeepTex = "keep-tex";
8888
export const kKeepTyp = "keep-typ";
8989
export const kPdfStandard = "pdf-standard";
90+
export const kPdfStandardApplied = "pdf-standard-applied";
9091
export const kKeepIpynb = "keep-ipynb";
9192
export const kKeepSource = "keep-source";
9293
export const kVariant = "variant";

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ import {
3232
kPaperSize,
3333
kPdfEngine,
3434
kPdfStandard,
35+
kPdfStandardApplied,
3536
kReferenceLocation,
3637
kShiftHeadingLevelBy,
3738
kTblCapLoc,
@@ -345,6 +346,12 @@ function createPdfFormat(
345346
}
346347
extras.pandoc.variables["pdfstandard"] = pdfstandardMap;
347348
}
349+
// Store applied standards in metadata for verapdf validation
350+
// (only standards that LaTeX actually supports, not the original list)
351+
if (standards.length > 0) {
352+
extras.metadata = extras.metadata || {};
353+
extras.metadata[kPdfStandardApplied] = standards;
354+
}
348355
}
349356

350357
return extras;
Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,23 @@
11
---
22
title: "LaTeX version + standards combined"
3+
lang: en
34
format: pdf
4-
pdf-standard: ["1.7", a-2b, ua-1]
5+
pdf-standard: ["1.7", a-2b]
56
keep-tex: true
67
_quarto:
78
tests:
9+
run:
10+
# verapdf validation not available on Windows CI
11+
not_os: windows
812
pdf:
913
noErrors: default
1014
ensureLatexFileRegexMatches:
11-
- ['\\DocumentMetadata\{', 'pdfversion=1\.7', 'pdfstandard=\{a-2b,ua-1\}', 'tagging=on']
15+
- ['\\DocumentMetadata\{', 'pdfversion=1\.7', 'pdfstandard=\{a-2b\}']
1216
- []
1317
---
1418

1519
# Test Document
1620

17-
This tests PDF 1.7 with PDF/A-2b + PDF/UA-1.
21+
This tests explicit PDF 1.7 version with PDF/A-2b standard.
22+
23+
PDF/A-2b requires PDF version 1.7 max, which matches the explicit version.
Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,24 @@
11
---
22
title: "LaTeX multiple PDF standards"
3+
lang: en
34
format: pdf
4-
pdf-standard: [a-2b, ua-1]
5+
pdf-standard: [a-4f, ua-2]
56
keep-tex: true
67
_quarto:
78
tests:
9+
run:
10+
# verapdf validation not available on Windows CI
11+
not_os: windows
812
pdf:
913
noErrors: default
1014
ensureLatexFileRegexMatches:
11-
- ['\\DocumentMetadata\{', 'pdfstandard=\{a-2b,ua-1\}', 'tagging=on']
15+
- ['\\DocumentMetadata\{', 'pdfstandard=\{a-4f,ua-2\}', 'tagging=on']
1216
- []
1317
---
1418

1519
# Test Document
1620

17-
This tests combined PDF/A-2b + PDF/UA-1 output.
21+
This tests combined PDF/A-4f + PDF/UA-2 output with LaTeX.
22+
23+
PDF/A-4f (file) and PDF/UA-2 are compatible - both use PDF 2.0 and
24+
pass verapdf validation together.
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
---
2+
title: "LaTeX filters unsupported ua-1"
3+
lang: en
4+
format: pdf
5+
pdf-standard: [a-2b, ua-1]
6+
keep-tex: true
7+
_quarto:
8+
tests:
9+
run:
10+
# verapdf validation not available on Windows CI
11+
not_os: windows
12+
pdf:
13+
noErrors: default
14+
ensureLatexFileRegexMatches:
15+
# LaTeX receives ua-1 in pdfstandard (it accepts it syntactically)
16+
- ['\\DocumentMetadata\{', 'pdfstandard=\{a-2b,ua-1\}', 'tagging=on']
17+
- []
18+
printsMessage:
19+
# ua-1 should be warned about as unsupported
20+
level: WARN
21+
regex: "PDF standard 'ua-1' is not supported by LaTeX"
22+
---
23+
24+
# Test: LaTeX Filters Unsupported Standards from Validation
25+
26+
This test verifies that when `pdf-standard: [a-2b, ua-1]` is specified:
27+
28+
1. LaTeX receives both standards in `\DocumentMetadata{pdfstandard={a-2b,ua-1}}`
29+
2. A warning is emitted that ua-1 is not supported by LaTeX
30+
3. verapdf validates ONLY against a-2b (not ua-1)
31+
4. The render succeeds because we don't try to validate unsupported standards
32+
33+
Without filtering, verapdf would fail because the PDF isn't actually PDF/UA-1 compliant
34+
(LaTeX only supports ua-2 for PDF/UA).

0 commit comments

Comments
 (0)