From d3385ba79025796ab3166876dc68f38595e822d0 Mon Sep 17 00:00:00 2001 From: "Kenneth G. Franqueiro" Date: Thu, 19 Dec 2024 12:27:53 -0500 Subject: [PATCH] Pin guidelines/* content when publishing 2.2 docs to w3.org (#4161) This applies the same publication-version-pinning logic added in #4007 for 2.1 docs, to 2.2 docs specifically when built for w3.org, so that guideline/SC and definition text included within informative docs matches the published recommendation. Local dev and gh-pages builds continue to run against `guidelines` in the local repository (effectively the Editor's Draft). The build uses the published recommendation whenever `WCAG_VERSION` is specified, so enabling this for w3.org builds only requires adding that environment variable explicitly to the `publish-w3c` script. The changes to `11ty/guidelines.ts` fix cases that were never exhibited in the 2.1 build, but came up when testing building 2.2 against the published recommendation. --- 11ty/guidelines.ts | 11 ++++++++++- package.json | 2 +- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/11ty/guidelines.ts b/11ty/guidelines.ts index 0dc8ace485..27cc3fd8ff 100644 --- a/11ty/guidelines.ts +++ b/11ty/guidelines.ts @@ -247,6 +247,15 @@ const loadRemoteGuidelines = async (version: WcagVersion) => { $("[role='note'] .marker").remove(); $("[role='note']").find("> div, > p").addClass("note").unwrap(); + // Convert data-plurals (present in publications) to data-lt + $("dfn[data-plurals]").each((_, el) => { + el.attribs["data-lt"] = (el.attribs["data-lt"] || "") + .split("|") + .concat(el.attribs["data-plurals"].split("|")) + .join("|"); + delete el.attribs["data-plurals"]; + }); + // Un-process bibliography references, to be processed by CustomLiquid $("cite:has(a.bibref:only-child)").each((_, el) => { const $el = $(el); @@ -255,7 +264,7 @@ const loadRemoteGuidelines = async (version: WcagVersion) => { // Remove generated IDs and markers from examples $(".example[id]").removeAttr("id"); - $(".example .marker:has(.self-link)").remove(); + $(".example > .marker").remove(); // Remove extra markup from headings so they can be parsed for names $("bdi").remove(); diff --git a/package.json b/package.json index f9b0601f58..78f8d48293 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,7 @@ "build": "tsx node_modules/@11ty/eleventy/cmd.cjs --config=eleventy.config.ts", "check": "tsc", "fmt": "prettier . -w", - "publish-w3c": "WCAG_MODE=publication npm run build && tsx 11ty/cp-cvs.ts", + "publish-w3c": "WCAG_VERSION=22 WCAG_MODE=publication npm run build && tsx 11ty/cp-cvs.ts", "publish-w3c:21": "WCAG_VERSION=21 WCAG_MODE=publication npm run build && WCAG_VERSION=21 tsx 11ty/cp-cvs.ts", "start": "tsx watch node_modules/@11ty/eleventy/cmd.cjs --config=eleventy.config.ts --serve --incremental" },