Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Include data-xref-type as another hint for autolinks #1585

Merged
merged 2 commits into from
Jun 6, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
4 changes: 2 additions & 2 deletions src/browserlib/extract-links.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ export default function () {
// carry their diff (e.g. W3C Recs with candidate corrections)
if (n.closest('.head, del')) return;
const pageUrl = n.href.split('#')[0];
// links generated by authoring tools have data-link-type set
let linkSet = n.dataset.linkType ? autolinks : rawlinks;
// links generated by authoring tools have data-link-type or data-xref-type set
let linkSet = n.dataset.linkType || n.dataset.xrefType ? autolinks : rawlinks;
if (!linkSet[pageUrl]) {
linkSet[pageUrl] = {anchors: new Set()};
}
Expand Down
4 changes: 1 addition & 3 deletions tests/crawl-test.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,15 +76,13 @@
"autolinks": {
"https://webidl.spec.whatwg.org/": {
"anchors": [
"Exposed",
"idl-DOMString"
]
}
},
"rawlinks": {
"https://webidl.spec.whatwg.org/": {
"anchors": [
"Exposed"
]
}
}
},
Expand Down
2 changes: 1 addition & 1 deletion tests/extract-links.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ 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-link-type="dfn">DOM Standard</a></p>`,
<p><a href="https://dom.spec.whatwg.org/#nodes" data-xref-type="dfn">DOM Standard</a></p>`,
res: {
autolinks: {
"https://dom.spec.whatwg.org/": {
Expand Down
Loading