Skip to content

Commit

Permalink
Number examples/notes when there are multiple in one SC or definition (
Browse files Browse the repository at this point in the history
…#4231)

Fixes #4229.

This adds logic akin to `numberNotes` and `renumberExamples` in
`wcag.js` (used in ReSpec post-processing) to the build system, to also
number notes and examples in informative docs when multiple appear in a
single success criterion or term definition.
  • Loading branch information
kfranqueiro authored Feb 19, 2025
1 parent ba5b725 commit 5320187
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions 11ty/CustomLiquid.ts
Original file line number Diff line number Diff line change
Expand Up @@ -563,6 +563,18 @@ export class CustomLiquid extends Liquid {
$el.prepend(`<p class="example-title marker">Example</p>`);
});

// Perform second pass over notes/examples, to number when there are multiple in one section or dd
$("#key-terms dd, #success-criterion").each((_, containerEl) => {
for (const selector of [".example-title", ".note-title"]) {
const $titles = $(containerEl).find(selector);
if ($titles.length > 1) {
$titles.each((i, el) => {
$(el).text(`${$(el).text()} ${i + 1}`);
});
}
}
});

// We don't need to do any more processing for index/about pages other than stripping comments
if (indexPattern.test(scope.page.inputPath)) return stripHtmlComments($.html());

Expand Down

0 comments on commit 5320187

Please sign in to comment.