Skip to content

Commit a38c0b4

Browse files
committed
axe-check docs
1 parent 3a7334a commit a38c0b4

File tree

3 files changed

+89
-0
lines changed

3 files changed

+89
-0
lines changed

_quarto.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,7 @@ website:
224224
- docs/output-formats/html-multi-format.qmd
225225
- docs/output-formats/html-lightbox-figures.qmd
226226
- docs/output-formats/html-publishing.qmd
227+
- docs/output-formats/html-accessibility.qmd
227228
- section: "PDF"
228229
contents:
229230
- docs/output-formats/pdf-basics.qmd
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
---
2+
title: "HTML Accessibility Checks"
3+
---
4+
5+
::: callout-note
6+
This feature was introduced in Quarto 1.8.
7+
:::
8+
9+
Quarto includes integrated support for [`axe-core`](https://github.com/dequelabs/axe-core), a broadly-supported, open source, industry standard tool for accessibility checks in HTML documents.
10+
11+
## Accessibility checks with `axe-core`
12+
13+
To enable the simplest form of accessibility checks in Quarto 1.8, add the `axe` YAML metadata configuration to HTML `format`s (`html`, `dashboard`, and `revealjs`):
14+
15+
``` yaml
16+
format:
17+
html:
18+
axe: true
19+
```
20+
21+
In this situation, if your webpage has accessibility violations that `axe-core` can catch, Quarto will produce console messages that are visible by opening your browser's development tools.
22+
23+
### Customization
24+
25+
Quarto supports two additional output formats for the accessibility checks, available through `output` option.
26+
27+
- `output: document`: embedded reports
28+
29+
``` yaml
30+
format:
31+
html:
32+
axe:
33+
output: document
34+
```
35+
36+
With this option, Quarto will generate a visible report of `axe-core` violations on the webpage itself. This is useful for visual inspection of a page. Note that with this setting, Quarto will always produce a report.
37+
38+
If you wish to use this feature, we recommend adding it to a "debug" [project profile](/docs/projects/profiles.qmd) to reduce the chance you will accidentally publish a website to production with these reports.
39+
40+
- `output: json`: JSON-formatted console output
41+
42+
``` yaml
43+
format:
44+
html:
45+
axe:
46+
output: json
47+
```
48+
49+
This option is useful if you're comfortable with browser automation tools such as [Puppeteer](https://pptr.dev/) and [Playwright](https://playwright.dev/), since it produces output to the console in a format that can be easily consumed.
50+
51+
Specifically, the JSON object produced is the result of running `axe-core`'s `run` method on the webpage. We defer to `axe-core`'s [documentation for full information on that object](https://github.com/dequelabs/axe-core).
52+
53+
- `output: console`
54+
55+
``` yaml
56+
format:
57+
html:
58+
axe:
59+
output: console
60+
```
61+
62+
This option is equivalent to `axe: true`.
63+
64+
## Example: insufficient contrast
65+
66+
As a minimal example of how this works in Quarto, consider this simple document:
67+
68+
``` qmd
69+
---
70+
title: Testing Quarto's accessibility checker
71+
format:
72+
html:
73+
axe:
74+
output: document
75+
---
76+
77+
This violates contrast rules: [insufficient contrast.]{style="color: #eee"}.
78+
```
79+
80+
This is the produced result visible on the page:
81+
82+
![The rendered webpage with an accessibility violation warning](images/axe-violation.png)
83+
84+
## Planned work: automated checks before publishing
85+
86+
Currently, this feature requires users to open the webpage in a [local preview](/docs/websites/index.html#website-preview), and it uses a CDN to load the `axe-core` library itself.
87+
88+
In the future, we envision a mode where every page of a website can be checked at the time of `quarto render` or `quarto publish` in order to reduce the amount of required manual intervention.
127 KB
Loading

0 commit comments

Comments
 (0)