Skip to content
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 17 additions & 3 deletions src/w3c/conformance.js
Original file line number Diff line number Diff line change
@@ -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";
Expand Down Expand Up @@ -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 `<section id="conformance">`. 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) {
Expand Down
19 changes: 19 additions & 0 deletions tests/spec/w3c/conformance-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = `
<section id="conformance" class="informative">
<p>CONFORMANCE</p>
</section>
<section>
<h2>my section</h2>
<p>MUST be tested.</p>
</section>
`;
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 = `
<section>
Expand Down
Loading