Skip to content

a11y - add support for tagpdf #13124

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 21 additions & 3 deletions src/resources/editor/tools/vs-code.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -24323,6 +24323,10 @@ var require_yaml_intelligence_resources = __commonJS({
"List execution engines you want to give priority when determining\nwhich engine should render a notebook. If two engines have support for a\nnotebook, the one listed earlier will be chosen. Quarto\u2019s default order\nis \u2018knitr\u2019, \u2018jupyter\u2019, \u2018markdown\u2019, \u2018julia\u2019.",
"When defined, run axe-core accessibility tests on the document.",
"If set, output axe-core results on console. <code>json</code>:\nproduce structured output; <code>console</code>: print output to\njavascript console; <code>document</code>: produce a visual report of\nviolations in the document itself.",
{
short: "If true, enable <code>tagpdf</code> support for accessible PDFs",
long: "If true, enable <code>tagpdf</code> support for accessible PDFs. This\nwill ensure that the PDF is tagged and that images have alt text. Note\nthat this requires a LaTeX engine that supports PDF tagging (e.g.,\n<code>lualatex</code>)."
},
"The logo image.",
"Project configuration.",
"Project type (<code>default</code>, <code>website</code>,\n<code>book</code>, or <code>manuscript</code>)",
Expand Down Expand Up @@ -24901,12 +24905,12 @@ var require_yaml_intelligence_resources = __commonJS({
mermaid: "%%"
},
"handlers/mermaid/schema.yml": {
_internalId: 197480,
_internalId: 197628,
type: "object",
description: "be an object",
properties: {
"mermaid-format": {
_internalId: 197472,
_internalId: 197620,
type: "enum",
enum: [
"png",
Expand All @@ -24922,7 +24926,7 @@ var require_yaml_intelligence_resources = __commonJS({
exhaustiveCompletions: true
},
theme: {
_internalId: 197479,
_internalId: 197627,
type: "anyOf",
anyOf: [
{
Expand Down Expand Up @@ -24986,6 +24990,20 @@ var require_yaml_intelligence_resources = __commonJS({
]
},
description: "When defined, run axe-core accessibility tests on the document."
},
{
name: "tagpdf",
tags: {
formats: [
"pdf"
]
},
schema: "boolean",
default: true,
description: {
short: "If true, enable `tagpdf` support for accessible PDFs",
long: "If true, enable `tagpdf` support for accessible PDFs. This will\nensure that the PDF is tagged and that images have alt text.\nNote that this requires a LaTeX engine that supports PDF tagging\n(e.g., `lualatex`).\n"
}
}
],
"schema/document-typst.yml": [
Expand Down

Large diffs are not rendered by default.

24 changes: 21 additions & 3 deletions src/resources/editor/tools/yaml/web-worker.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 21 additions & 3 deletions src/resources/editor/tools/yaml/yaml-intelligence-resources.json
Original file line number Diff line number Diff line change
Expand Up @@ -17295,6 +17295,10 @@
"List execution engines you want to give priority when determining\nwhich engine should render a notebook. If two engines have support for a\nnotebook, the one listed earlier will be chosen. Quarto’s default order\nis ‘knitr’, ‘jupyter’, ‘markdown’, ‘julia’.",
"When defined, run axe-core accessibility tests on the document.",
"If set, output axe-core results on console. <code>json</code>:\nproduce structured output; <code>console</code>: print output to\njavascript console; <code>document</code>: produce a visual report of\nviolations in the document itself.",
{
"short": "If true, enable <code>tagpdf</code> support for accessible PDFs",
"long": "If true, enable <code>tagpdf</code> support for accessible PDFs. This\nwill ensure that the PDF is tagged and that images have alt text. Note\nthat this requires a LaTeX engine that supports PDF tagging (e.g.,\n<code>lualatex</code>)."
},
"The logo image.",
"Project configuration.",
"Project type (<code>default</code>, <code>website</code>,\n<code>book</code>, or <code>manuscript</code>)",
Expand Down Expand Up @@ -17873,12 +17877,12 @@
"mermaid": "%%"
},
"handlers/mermaid/schema.yml": {
"_internalId": 197480,
"_internalId": 197628,
"type": "object",
"description": "be an object",
"properties": {
"mermaid-format": {
"_internalId": 197472,
"_internalId": 197620,
"type": "enum",
"enum": [
"png",
Expand All @@ -17894,7 +17898,7 @@
"exhaustiveCompletions": true
},
"theme": {
"_internalId": 197479,
"_internalId": 197627,
"type": "anyOf",
"anyOf": [
{
Expand Down Expand Up @@ -17958,6 +17962,20 @@
]
},
"description": "When defined, run axe-core accessibility tests on the document."
},
{
"name": "tagpdf",
"tags": {
"formats": [
"pdf"
]
},
"schema": "boolean",
"default": true,
"description": {
"short": "If true, enable `tagpdf` support for accessible PDFs",
"long": "If true, enable `tagpdf` support for accessible PDFs. This will\nensure that the PDF is tagged and that images have alt text.\nNote that this requires a LaTeX engine that supports PDF tagging\n(e.g., `lualatex`).\n"
}
}
],
"schema/document-typst.yml": [
Expand Down
4 changes: 4 additions & 0 deletions src/resources/filters/layout/pandoc3_figure.lua
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,10 @@ function render_pandoc3_figure()
if scope_utils.lookup_class(scope, "column-margin") then
image.classes:insert("column-margin")
end
if image.attributes['fig-alt'] ~= nil then
image.attributes['alt'] = image.attributes['fig-alt']
image.attributes['fig-alt'] = nil
end
return latexImageFigure(image)
end

Expand Down
10 changes: 10 additions & 0 deletions src/resources/formats/pdf/pandoc/passoptions.latex
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,13 @@ $endif$
$if(CJKmainfont)$
\PassOptionsToPackage{space}{xeCJK}
$endif$
$if(tagpdf)$
\DocumentMetadata{%
lang = en-us,
pdfversion = 2.0,
pdfstandard = ua-2,
tagging = on,
tagging-setup = {math/setup=mathml-SE}
}
\tagpdfsetup{activate, tabsorder=structure}
Comment on lines +11 to +18
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if this should be configurable for users who desire to configure the \DocumentMetadata. There are a few options with different values like lang or pdfstandard

Documented at https://mirrors.ctan.org/macros/latex/required/latex-lab/documentmetadata-support-code.pdf

I guess this is how Pandoc would add it in its template.

Otherwise, if we put it in its own partials (taggedpdf.tex for example), then this would be really easy for a user to pass its own version with modified options. Could be worth it if we are not sure yet what to expose as config

pdf:
  tagpdf:
    pdfstandard: ...

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like having a taggedpdf.tex partial.

$endif$
13 changes: 13 additions & 0 deletions src/resources/schema/document-a11y.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,16 @@
enum: [json, console, document]
description: "If set, output axe-core results on console. `json`: produce structured output; `console`: print output to javascript console; `document`: produce a visual report of violations in the document itself."
description: "When defined, run axe-core accessibility tests on the document."

- name: tagpdf
tags:
formats: [pdf]
schema: boolean
default: true
description:
short: "If true, enable `tagpdf` support for accessible PDFs"
long: |
If true, enable `tagpdf` support for accessible PDFs. This will
ensure that the PDF is tagged and that images have alt text.
Note that this requires a LaTeX engine that supports PDF tagging
(e.g., `lualatex`).
19 changes: 19 additions & 0 deletions tests/docs/smoke-all/latex/tagpdf.qmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
format:
pdf:
tagpdf: true
keep-tex: true
title: This is a tagpdf test
_quarto:
tests:
latex:
ensurePdfRegexMatches:
-
- "tagging = on"
- 'alt={alt text 2 here}'
- []
---

## This is a test

![A caption](./an-image.png){fig-alt="alt text 2 here"}
Loading