Skip to content

Commit f7d8bd1

Browse files
Add cross-linking to external specs in editor's draft.
1 parent 78d5806 commit f7d8bd1

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

index.html

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1553,5 +1553,23 @@ <h1>Acknowledgements</h1>
15531553
[[HTML5]] and his useful comments.
15541554
</section>
15551555

1556+
<script>
1557+
try {
1558+
var urlMap = {
1559+
"DOM4": "http://www.w3.org/TR/dom/#",
1560+
"HTML5": "http://www.w3.org/TR/html5/single-page.html#",
1561+
};
1562+
[].forEach.call(document.querySelectorAll("[class=externalDFN]"), function (el) {
1563+
var key = el.getAttribute("data-spec");
1564+
if (!key) throw Error("Missed a 'data-spec' attribute on an class='externalDFN' reference for title='" + el.title + "'");
1565+
if (typeof urlMap[key] == "undefined") throw Error("Unknown 'data-spec' attribute value '" + key + "'");
1566+
var link = el.title;
1567+
if (link == "") throw Error("title value not provided on external reference for 'data-spec' attribute value '" + key + "'");
1568+
if (el.localName != "a") throw Error("Reference used on a non-anchor element: '" + el.localName + "'");
1569+
el.removeAttribute("data-spec");
1570+
el.href = urlMap[key] + link;
1571+
});
1572+
} catch (ex) { alert(ex); }
1573+
</script>
15561574
</body>
15571575
</html>

0 commit comments

Comments
 (0)