mirror of
https://github.com/jsdoc/jsdoc.git
synced 2025-12-08 19:46:11 +00:00
Make anchors work again and highlight the anchored line.
This commit is contained in:
parent
86db992861
commit
6ce7a5a36f
@ -1,17 +1,19 @@
|
||||
(function() {
|
||||
var counter = 0;
|
||||
var numbered;
|
||||
var source = document.getElementsByClassName('prettyprint source');
|
||||
var source = document.getElementsByClassName('prettyprint source linenums');
|
||||
var i = 0, lineNumber = 0, lineId, lines, totalLines, anchorHash;
|
||||
|
||||
if (source && source[0]) {
|
||||
source = source[0].getElementsByTagName('code')[0];
|
||||
anchorHash = document.location.hash.substring(1);
|
||||
lines = source[0].getElementsByTagName('li');
|
||||
totalLines = lines.length;
|
||||
|
||||
numbered = source.innerHTML.split('\n');
|
||||
numbered = numbered.map(function(item) {
|
||||
counter++;
|
||||
return '<span id="line' + counter + '" class="line"></span>' + item;
|
||||
});
|
||||
|
||||
source.innerHTML = numbered.join('\n');
|
||||
for (; i < totalLines; i++) {
|
||||
lineNumber++;
|
||||
lineId = 'line' + lineNumber;
|
||||
lines[i].id = lineId;
|
||||
if (lineId == anchorHash) {
|
||||
lines[i].className += ' selected';
|
||||
}
|
||||
}
|
||||
}
|
||||
})();
|
||||
})();
|
||||
@ -251,6 +251,11 @@ h6
|
||||
border-left: 3px #ddd solid;
|
||||
}
|
||||
|
||||
.prettyprint .linenums li.selected code
|
||||
{
|
||||
background-color: lightyellow;
|
||||
}
|
||||
|
||||
.params, .props
|
||||
{
|
||||
border-spacing: 0;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user