forked from forgejo/forgejo
linenums
This commit is contained in:
parent
c6bd723ce1
commit
de956c4776
6 changed files with 82 additions and 13 deletions
|
@ -68,9 +68,30 @@ var Gogits = {
|
|||
Gogits.renderMarkdown = function () {
|
||||
var $md = $('.markdown');
|
||||
var $pre = $md.find('pre > code').parent();
|
||||
$pre.addClass("prettyprint");
|
||||
$pre.addClass('prettyprint');
|
||||
prettyPrint();
|
||||
|
||||
var $lineNums = $pre.parent().siblings('.lines-num');
|
||||
if($lineNums.length > 0){
|
||||
var nums = $pre.find('ol.linenums > li').length;
|
||||
for(var i=0;i < nums;i++){
|
||||
$lineNums.append('<span id="L'+i+'" rel=".L'+i+'">'+(i+1)+'</span>');
|
||||
}
|
||||
|
||||
var last;
|
||||
$(document).on('click', '.lines-num span', function(){
|
||||
var $e = $(this);
|
||||
console.log($e.parent().siblings('.lines-code').find('ol.linenums > ' + $e.attr('rel')));
|
||||
console.log('ol.linenums > ' + $e.attr('rel'));
|
||||
if(last){
|
||||
last.removeClass('active');
|
||||
}
|
||||
last = $e.parent().siblings('.lines-code').find('ol.linenums > ' + $e.attr('rel'));
|
||||
last.addClass('active');
|
||||
window.location.href = '#' + $e.attr('id');
|
||||
});
|
||||
}
|
||||
|
||||
// Set anchor.
|
||||
var headers = {};
|
||||
$md.find('h1, h2, h3, h4, h5, h6').each(function () {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue