From cf795b0cf5bb76ced10578385e82acc6e327efcb Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Thu, 15 May 2025 11:37:50 -0700 Subject: Fix context writer/template to produce tagged PDFs. As before, the `tagging` extension must be enabled. We now add the command that tells ConTeXt to start tagging. Closes #10846. --- MANUAL.txt | 5 ++--- data/templates/default.context | 4 ++++ src/Text/Pandoc/Writers/ConTeXt.hs | 1 + 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/MANUAL.txt b/MANUAL.txt index 5c14f9dc7..0891a8096 100644 --- a/MANUAL.txt +++ b/MANUAL.txt @@ -7590,10 +7590,9 @@ ConTeXt always produces tagged PDFs, but the quality depends on the input. The default ConTeXt markup generated by pandoc is optimized for readability and reuse, not tagging. Enable the [`tagging`](#extension--tagging) format extension to force markup -that is optimized for tagging. This can be combined with the -`pdfa` variable to generate standard-compliant PDFs. E.g.: +that is optimized for tagging. For example: - pandoc --to=context+tagging -V pdfa=3a + pandoc -t context+tagging doc.md -o doc.pdf A recent `context` version should be used, as older versions contained a bug that lead to invalid PDF metadata. diff --git a/data/templates/default.context b/data/templates/default.context index 4814333cd..a2a5a45bb 100644 --- a/data/templates/default.context +++ b/data/templates/default.context @@ -1,3 +1,7 @@ +$if(tagging)$ +\setupbackend[format=pdf/ua-2] +\setuptagging[state=start] +$endif$ $if(context-lang)$ \mainlanguage[$context-lang$] $endif$ diff --git a/src/Text/Pandoc/Writers/ConTeXt.hs b/src/Text/Pandoc/Writers/ConTeXt.hs index 9e35c803b..65a0fa9dd 100644 --- a/src/Text/Pandoc/Writers/ConTeXt.hs +++ b/src/Text/Pandoc/Writers/ConTeXt.hs @@ -117,6 +117,7 @@ pandocToConTeXt options (Pandoc meta blocks) = do "subsubsubsection","subsubsubsubsection"]) $ defField "body" main $ defField "layout" layoutFromMargins + $ defField "tagging" (isEnabled Ext_tagging options) $ defField "number-sections" (writerNumberSections options) $ defField "csl-refs" (stHasCslRefs st) $ defField "csl-hanging-indent" (stCslHangingIndent st) -- cgit v1.2.3