diff --git a/src/w3c/conformance.js b/src/w3c/conformance.js index 63c09c04c5..e0f2744512 100644 --- a/src/w3c/conformance.js +++ b/src/w3c/conformance.js @@ -1,7 +1,12 @@ // @ts-check // Module w3c/conformance // Handle the conformance section properly. -import { getIntlData, htmlJoinAnd, showWarning } from "../core/utils.js"; +import { + getIntlData, + htmlJoinAnd, + showError, + showWarning, +} from "../core/utils.js"; import { html } from "../core/import-maps.js"; import { renderInlineCitation } from "../core/render-biblio.js"; import { rfc2119Usage } from "../core/inlines.js"; @@ -75,9 +80,18 @@ function processConformance(conformance, conf) { } export function run(conf) { + /** @type {HTMLElement | null} */ const conformance = document.querySelector("section#conformance"); - if (conformance && !conformance.classList.contains("override")) { - processConformance(conformance, conf); + if (conformance) { + if (conformance.classList.contains("informative")) { + const msg = "The conformance section cannot be marked as informative."; + const hint = + 'Remove `class="informative"` from `
`. Conformance sections are normative by definition.'; + showError(msg, name, { hint, elements: [conformance] }); + } + if (!conformance.classList.contains("override")) { + processConformance(conformance, conf); + } } // Warn when there are RFC2119/RFC8174 keywords, but not conformance section if (!conformance && Object.keys(rfc2119Usage).length) { diff --git a/tests/spec/w3c/conformance-spec.js b/tests/spec/w3c/conformance-spec.js index c5cfcc93b2..03d949e432 100644 --- a/tests/spec/w3c/conformance-spec.js +++ b/tests/spec/w3c/conformance-spec.js @@ -64,6 +64,25 @@ describe("W3C — Conformance", () => { expect(doc.querySelectorAll("#conformance .rfc2119")).toHaveSize(0); }); + it("errors when the conformance section is marked informative", async () => { + const body = ` +
+

CONFORMANCE

+
+
+

my section

+

MUST be tested.

+
+ `; + const doc = await makeRSDoc(makeStandardOps({}, body)); + const errors = doc.respec.errors.filter( + e => e.plugin === "w3c/conformance" + ); + expect(errors).toHaveSize(1); + expect(errors[0].message).toContain("cannot be marked as informative"); + expect(errors[0].hint).toContain("informative"); + }); + it("allows conformance section to be completely overridden via .override css class", async () => { const body = `