From 53201876ac873be00f70ce514e41a976db01f0ae Mon Sep 17 00:00:00 2001 From: "Kenneth G. Franqueiro" Date: Wed, 19 Feb 2025 13:59:03 -0500 Subject: [PATCH] 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. --- 11ty/CustomLiquid.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/11ty/CustomLiquid.ts b/11ty/CustomLiquid.ts index 3cf11c248e..b8f550f022 100644 --- a/11ty/CustomLiquid.ts +++ b/11ty/CustomLiquid.ts @@ -563,6 +563,18 @@ export class CustomLiquid extends Liquid { $el.prepend(`

Example

`); }); + // 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());