make highlighter generate links to .css files mentioned in comments
This commit is contained in:
parent
d30c6209f6
commit
cf7d1ea23c
2 changed files with 23 additions and 1 deletions
|
@ -31,6 +31,7 @@ body{background-color: rgb(60,50,70); color: silver; margin: 0px }
|
|||
}
|
||||
|
||||
a{ color: rgb(100,150,200); margin-inline-start: 1ch }
|
||||
pre a{ margin: 0 }
|
||||
a:visited{ color: rgb(150,100,200) }
|
||||
a:hover{ color: rgb(200,150,100) }
|
||||
pre:empty{ display: none }
|
||||
|
|
|
@ -294,7 +294,28 @@ const Highlighter = new(function(){
|
|||
}
|
||||
|
||||
|
||||
}else{
|
||||
} else if(type === "comment"){
|
||||
let linksToFile = token.match(/[\w-\.]+\.css/g);
|
||||
if(linksToFile && linksToFile.length){
|
||||
let linkIdx = 0;
|
||||
let fromIdx = 0;
|
||||
while(linkIdx < linksToFile.length){
|
||||
let part = linksToFile[linkIdx++];
|
||||
let idx = token.indexOf(part);
|
||||
n.append(token.substring(fromIdx,idx));
|
||||
let link = document.createElement("a");
|
||||
link.textContent = part;
|
||||
link.href = `https://github.com/MrOtherGuy/firefox-csshacks/tree/master/chrome/${part}`;
|
||||
link.target = "_blank";
|
||||
n.appendChild(link);
|
||||
fromIdx = idx + part.length;
|
||||
}
|
||||
n.append(token.substring(fromIdx));
|
||||
}else{
|
||||
n.textContent = c || token
|
||||
}
|
||||
}
|
||||
else{
|
||||
n.textContent = c || token;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue