Skip to content

Commit 5566379

Browse files
authored
Drop "Appendix" prefix from heading number (#1886)
We expect heading "numbers" to be actual numbers or letters but appendix sections in RFCs typically start with "Appendix", e.g.: https://www.rfc-editor.org/rfc/rfc8610#appendix-A Headings extraction produced "Appendix A" as heading number, which fails schema validation. This update drops the "Appendix" prefix to get back to "A".
1 parent 8ce6a33 commit 5566379

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

src/browserlib/extract-headings.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export default function (spec, idToHeading) {
3333
.replace(/^\s*\./, '')
3434
.trim(),
3535
level: headingLevel,
36-
number: headingNumber
36+
number: headingNumber.replace(/\s*appendix\s+/i, '')
3737
};
3838
});
3939

test/extract-headings.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,16 @@ const testHeadings = [
8383
</pre>`,
8484
res: [{id: "title", href: "about:blank#title", title: "Title", number: "3.1", level: 2}]
8585
},
86+
{
87+
title: "deals with appendices in www.rfc-editor.org RFCs",
88+
html: `<pre>
89+
<span class="h3">
90+
<a class="selflink" id="title" href="#title">Appendix A</a>.
91+
Title
92+
</span>
93+
</pre>`,
94+
res: [{id: "title", href: "about:blank#title", title: "Title", number: "A", level: 1}]
95+
},
8696
];
8797

8898
describe("Test headings extraction", function () {

0 commit comments

Comments
 (0)