Skip to content

Commit

Permalink
Classify links in bikeshed generated index as automatic
Browse files Browse the repository at this point in the history
  • Loading branch information
dontcallmedom committed Jun 10, 2024
1 parent 1b9b86d commit 7103647
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/browserlib/extract-links.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ export default function () {
if (n.closest('.head, del')) return;
const pageUrl = n.href.split('#')[0];
// links generated by authoring tools have data-link-type or data-xref-type set
let linkSet = n.dataset.linkType || n.dataset.xrefType ? autolinks : rawlinks;
// 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;
if (!linkSet[pageUrl]) {
linkSet[pageUrl] = {anchors: new Set()};
}
Expand Down
5 changes: 3 additions & 2 deletions tests/extract-links.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,13 @@ const testLinks = [
title: "extracts links with fragments",
html: `<h1 id=title>Title</h1>
<p><a href="https://dom.spec.whatwg.org/#ranges">DOM Standard</a></p>
<p><a href="https://dom.spec.whatwg.org/#nodes" data-xref-type="dfn">DOM Standard</a></p>`,
<p><a href="https://dom.spec.whatwg.org/#nodes" data-xref-type="dfn">DOM Standard</a></p><ul class="index"><li><aside><a href="https://dom.spec.whatwg.org/#element">Element</a></aside></li></ul>`,
res: {
autolinks: {
"https://dom.spec.whatwg.org/": {
"anchors": [
"nodes"
"nodes",
"element"
]
}
},
Expand Down

0 comments on commit 7103647

Please sign in to comment.