Skip to content

Commit 5320187

Browse files
authored
Number examples/notes when there are multiple in one SC or definition (#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.
1 parent ba5b725 commit 5320187

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

11ty/CustomLiquid.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -563,6 +563,18 @@ export class CustomLiquid extends Liquid {
563563
$el.prepend(`<p class="example-title marker">Example</p>`);
564564
});
565565

566+
// Perform second pass over notes/examples, to number when there are multiple in one section or dd
567+
$("#key-terms dd, #success-criterion").each((_, containerEl) => {
568+
for (const selector of [".example-title", ".note-title"]) {
569+
const $titles = $(containerEl).find(selector);
570+
if ($titles.length > 1) {
571+
$titles.each((i, el) => {
572+
$(el).text(`${$(el).text()} ${i + 1}`);
573+
});
574+
}
575+
}
576+
});
577+
566578
// We don't need to do any more processing for index/about pages other than stripping comments
567579
if (indexPattern.test(scope.page.inputPath)) return stripHtmlComments($.html());
568580

0 commit comments

Comments
 (0)