mirror of
https://github.com/go-gitea/gitea.git
synced 2024-05-11 05:55:29 +00:00
linenums
This commit is contained in:
@ -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 () {
|
||||
|
Reference in New Issue
Block a user