Skip to content

Commit c56f6cb

Browse files
authored
Fix skipped heading levels in markdown headings (#2227)
* Heading order fixes * Remove extra h1 and reflow * Fix headings that should have been "captions" * Update freeze
1 parent 4b057f9 commit c56f6cb

39 files changed

Lines changed: 192 additions & 126 deletions

File tree

‎.claude/rules/docs-authoring.md‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,7 @@ When referring to a Quarto format by its identifier (the value used in `format:`
2222
## Toolbar icons
2323

2424
Refer to a UI control by its name in bold, then "button" if it is one, then the icon as a decorative image: `**Render** button ![](images/rstudio-render-button.png){.ui-icon alt="" width="25" height="20"}`. Never wrap icons or control names in `<kbd>` (it is for keyboard input, and `kbd.js` uppercases one-word `<kbd>` text on macOS). Never leave an icon as the only name for a control. Use the name the control itself exposes (label, tooltip, or accessible name). See the "Toolbar Icons" section of `_style-guide.md`.
25+
26+
## Headings and example labels
27+
28+
Use a heading only to start a section, and never skip a level. A label for one example ("Markdown Syntax", "Output", "HTML output", a theme name under a screenshot) is a caption, not a heading. Label code blocks with `filename="..."`, images with a caption (plus `fig-cap-location: top` for a sequence of images), output with a lead-in sentence ("This renders as:"), and source/output pairs with a table. A bold paragraph is the fallback. Never use `{.unlisted}` headings as captions. When you fix an axe `heading-order` finding, first decide if the skipped heading is a real section. If it is a caption, replace it; do not change its level. See the "Headings and Example Labels" section of `_style-guide.md`.

‎_freeze/docs/authoring/tables/execute-results/html.json‎

Lines changed: 2 additions & 2 deletions
Large diffs are not rendered by default.

‎_freeze/docs/computations/execution-options/execute-results/html.json‎

Lines changed: 2 additions & 2 deletions
Large diffs are not rendered by default.

‎_freeze/docs/output-formats/html-code/execute-results/html.json‎

Lines changed: 2 additions & 2 deletions
Large diffs are not rendered by default.
4.88 KB
Loading
-2.99 KB
Loading

‎_freeze/docs/presentations/revealjs/demo/index/execute-results/html.json‎

Lines changed: 4 additions & 4 deletions
Large diffs are not rendered by default.

‎_freeze/site_libs/revealjs/dist/theme/quarto-2740581606dc327e82f18f789b69d8a0.css‎

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎_quarto.yml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -708,6 +708,7 @@ format:
708708
filters:
709709
- filters/tools-tabset.lua
710710
- filters/color-box.lua
711+
- filters/shift-headings.lua
711712
- at: post-quarto
712713
path: filters/include-dark.lua
713714

‎_style-guide.md‎

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,3 +101,36 @@ Use the **Render** button ![](images/rstudio-render-button.png){.ui-icon alt=""
101101
```
102102

103103
The `.ui-icon` class (`theme.scss` and `theme-dark.scss`) gives the image the same key-cap look as `<kbd>` in the light and dark themes.
104+
105+
## Headings and Example Labels
106+
107+
Use a heading only when it starts a section. A section continues until the next heading of the same level or higher. Screen readers use headings to move through a page, and the page TOC lists them.
108+
109+
Do not skip heading levels. After `##`, the next level is `###`.
110+
111+
A short label for one example is a caption, not a heading. Labels such as "Markdown Syntax", "Output", "HTML output", and "Arrow (light)" are captions. If you use a heading for a caption, the text after the example becomes part of the caption's section. This is incorrect when that text applies to the whole section.
112+
113+
Use one of these patterns for a caption:
114+
115+
* For a code block, use the `filename` attribute. The label shows in the header of the block.
116+
117+
````markdown
118+
``` {.markdown filename="Markdown Syntax"}
119+
| Right | Left |
120+
|------:|:-----|
121+
```
122+
````
123+
124+
* For an image, use the image caption. The caption becomes a `<figcaption>` for the image. If a page shows several captioned images in a sequence, set `fig-cap-location: top` in the page front matter. Then each caption is directly above its image.
125+
126+
```markdown
127+
![Arrow (light)](images/arrow.png){fig-alt="A block of code showcasing the Arrow (light) theme."}
128+
```
129+
130+
* For rendered output that follows its source, write a lead-in sentence, for example "This renders as:".
131+
132+
* For a set of source and output pairs, use a table with `Markdown Syntax` and `Output` column headers. See "Other Blocks" in `docs/authoring/markdown-basics.qmd`.
133+
134+
* For output that has no other pattern, use a bold label paragraph, for example `**PDF output**`.
135+
136+
Do not add `{.unlisted}` to a heading to hide a caption from the TOC. The heading is still in the page structure.

0 commit comments

Comments
 (0)