Skip to content

Commit 7233e92

Browse files
committed
Improve handling of auto-links from lexicon
1 parent 6499011 commit 7233e92

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

lexicon.js

+8-10
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,20 @@ fetch("../lexicon.json").then(r => r.json())
33
const alreadyDone = {};
44
[...document.querySelectorAll("a.dfn")].forEach(a => {
55
if (lexicon[a.textContent] && !alreadyDone[a.textContent]) {
6-
if (lexicon[a.textContent].href) {
7-
a.href = lexicon[a.textContent].href;
8-
return;
6+
let target = lexicon[a.textContent];
7+
if (target.alias) {
8+
target = lexicon[target.alias];
99
}
10-
let dfnTarget;
11-
if (!lexicon[a.textContent].alias) {
12-
dfnTarget = a.textContent;
13-
} else {
14-
dfnTarget = lexicon[a.textContent].alias;
10+
if (target.href) {
11+
a.href = target.href;
12+
return;
1513
}
16-
const dfnId = dfnTarget.toLowerCase().replace(/[^a-z0-9]/g, '');
14+
const dfnId = target.toLowerCase().replace(/[^a-z0-9]/g, '');
1715

1816
const dfn = document.createElement("p");
1917
dfn.id = dfnId;
2018
dfn.className = "hidden";
21-
dfn.innerHTML = lexicon[dfnTarget];
19+
dfn.innerHTML = target;
2220
document.getElementById("lexicon").appendChild(dfn);
2321

2422
a.className = "js-simple-tooltip";

0 commit comments

Comments
 (0)