diff --git a/src/browserlib/extract-links.mjs b/src/browserlib/extract-links.mjs index 2cb31699..8578b122 100644 --- a/src/browserlib/extract-links.mjs +++ b/src/browserlib/extract-links.mjs @@ -24,12 +24,13 @@ export default function () { // self, the GitHub repo, the implementation report, and other // documents that don't need to appear in the list of references. // Also ignore links in elements that appear when specs - // carry their diff (e.g. W3C Recs with candidate corrections) - if (n.closest('.head, del')) return; + // carry their diff (e.g. W3C Recs with candidate corrections). + // And then ignore links in aside dfn panels. They only contain internal + // links or links that already appear elsewhere in the spec. + if (n.closest('.head, del, .dfn-panel')) return; const pageUrl = n.href.split('#')[0]; // links generated by authoring tools have data-link-type or data-xref-type set - // Bikeshed also adds automatic untyped links in the generatedindex ("ul.index aside") - let linkSet = n.dataset.linkType || n.dataset.xrefType || n.closest("ul.index aside") ? autolinks : rawlinks; + let linkSet = n.dataset.linkType || n.dataset.xrefType ? autolinks : rawlinks; if (!linkSet[pageUrl]) { linkSet[pageUrl] = {anchors: new Set()}; } diff --git a/tests/extract-links.js b/tests/extract-links.js index fd1408f2..5f57024f 100644 --- a/tests/extract-links.js +++ b/tests/extract-links.js @@ -44,13 +44,12 @@ const testLinks = [ title: "extracts links with fragments", html: `

Title

DOM Standard

-

DOM Standard

`, +

DOM Standard

`, res: { autolinks: { "https://dom.spec.whatwg.org/": { "anchors": [ - "nodes", - "element" + "nodes" ] } }, @@ -63,6 +62,20 @@ const testLinks = [ } } }, + + { + title: "does not extract links in aside dfns panels", + html: `

Title

+ + +`, + res: { + autolinks: {}, + rawlinks: {} + } + }, ]; describe("Links extraction", function () {