Verified Commit 02e3b1e6 authored by Camil Staps's avatar Camil Staps 🚀

Add links in highlighted source code

parent c5015c56
......@@ -4,6 +4,10 @@ body, html {
padding: 0;
}
a.hidden {
text-decoration: none;
}
/* Main boxes */
#container {
position: relative;
......
......@@ -29,6 +29,28 @@ function search(query) {
searchfield.focus();
}
function highlightCallback(span, cls, str) {
var abbrs = {
'classname classname-generic': 'class',
'classname': 'class',
'funcname funcname-onlyused': 'fun',
'funcname': 'fun',
'generic': 'gen',
'type': 'td',
};
if (typeof abbrs[cls] != 'undefined') {
console.log(abbrs[cls]);
if (document.getElementById(abbrs[cls] + '-' + str) != null) {
return '<a class="hidden" href="#' + abbrs[cls] + '-' + str + '">' + span + '</a>';
} else {
return '<a class="hidden" href="javascript:search(\'' + str + '\');">' + span + '</a>';
}
} else {
return span;
}
}
(function(){
/* Resizable sidebar */
let sidebar = document.getElementById('sidebar');
......@@ -64,13 +86,13 @@ function search(query) {
/* Highlight Clean code */
let codes = document.getElementsByClassName('clean-code');
for (let i = 0; i < codes.length; i++) {
codes[i].innerHTML = highlightClean(codes[i].innerText);
codes[i].innerHTML = highlightClean(codes[i].innerText, highlightCallback);
}
/* Markup Clean documentation */
let docs = document.getElementsByClassName('clean-doc');
for (let i = 0; i < docs.length; i++) {
docs[i].innerHTML = docs[i].innerText.markup(undefined, function(link) {
docs[i].innerHTML = docs[i].innerText.markup(highlightCallback, function(link) {
return '<a href="javascript:search(\'' + link + '\');">' + link + '</a>';
});
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment