mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-11-09 19:31:21 +01:00
fix code view indentation
This commit is contained in:
parent
97e82a0ff6
commit
559cd63fc5
3 changed files with 29 additions and 24 deletions
|
@ -135,13 +135,12 @@
|
||||||
box-shadow: inset 40px 0 0 #f5f5f5, inset 41px 0 0 #ccc;
|
box-shadow: inset 40px 0 0 #f5f5f5, inset 41px 0 0 #ccc;
|
||||||
}
|
}
|
||||||
|
|
||||||
.markdown > pre > code,
|
.markdown > pre > code {
|
||||||
.markdown > pre > ol.linenums > li > code {
|
|
||||||
white-space: pre;
|
white-space: pre;
|
||||||
word-wrap: normal;
|
word-wrap: normal;
|
||||||
}
|
}
|
||||||
|
|
||||||
.markdown > pre > ol.linenums > li > code {
|
.markdown > pre > ol.linenums > li {
|
||||||
padding: 0 10px;
|
padding: 0 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -110,25 +110,6 @@ var Gogits = {
|
||||||
$pre.addClass('prettyprint linenums');
|
$pre.addClass('prettyprint linenums');
|
||||||
prettyPrint();
|
prettyPrint();
|
||||||
|
|
||||||
var $lineNums = $pre.parent().siblings('.lines-num');
|
|
||||||
if ($lineNums.length > 0) {
|
|
||||||
var nums = $pre.find('ol.linenums > li').length;
|
|
||||||
for (var i = 1; i <= nums; i++) {
|
|
||||||
$lineNums.append('<span id="L' + i + '" rel=".L' + i + '">' + i + '</span>');
|
|
||||||
}
|
|
||||||
|
|
||||||
var last;
|
|
||||||
$(document).on('click', '.lines-num span', function () {
|
|
||||||
var $e = $(this);
|
|
||||||
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.
|
// Set anchor.
|
||||||
var headers = {};
|
var headers = {};
|
||||||
$md.find('h1, h2, h3, h4, h5, h6').each(function () {
|
$md.find('h1, h2, h3, h4, h5, h6').each(function () {
|
||||||
|
@ -148,6 +129,30 @@ var Gogits = {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Gogits.renderCodeView = function () {
|
||||||
|
$('.code-view .lines-code > pre').each(function(){
|
||||||
|
var $pre = $(this);
|
||||||
|
var $lineNums = $pre.parent().siblings('.lines-num');
|
||||||
|
if ($lineNums.length > 0) {
|
||||||
|
var nums = $pre.find('ol.linenums > li').length;
|
||||||
|
for (var i = 1; i <= nums; i++) {
|
||||||
|
$lineNums.append('<span id="L' + i + '" rel=".L' + i + '">' + i + '</span>');
|
||||||
|
}
|
||||||
|
|
||||||
|
var last;
|
||||||
|
$(document).on('click', '.lines-num span', function () {
|
||||||
|
var $e = $(this);
|
||||||
|
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');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
})(jQuery);
|
})(jQuery);
|
||||||
|
|
||||||
// ajax utils
|
// ajax utils
|
||||||
|
@ -177,6 +182,7 @@ function initCore() {
|
||||||
Gogits.initModals();
|
Gogits.initModals();
|
||||||
Gogits.initDropDown();
|
Gogits.initDropDown();
|
||||||
Gogits.renderMarkdown();
|
Gogits.renderMarkdown();
|
||||||
|
Gogits.renderCodeView();
|
||||||
}
|
}
|
||||||
|
|
||||||
function initRegister() {
|
function initRegister() {
|
||||||
|
|
|
@ -16,12 +16,12 @@
|
||||||
{{.FileContent|str2html}}
|
{{.FileContent|str2html}}
|
||||||
</div>
|
</div>
|
||||||
{{else}}
|
{{else}}
|
||||||
<div class="panel-body file-body file-code">
|
<div class="panel-body file-body file-code code-view">
|
||||||
<table>
|
<table>
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr>
|
<tr>
|
||||||
<td class="lines-num"></td>
|
<td class="lines-num"></td>
|
||||||
<td class="lines-code markdown"><pre class="linenums lang-{{.FileExt}}"><code>{{.FileContent}}</code></pre></td>
|
<td class="lines-code markdown"><pre class="prettyprint linenums lang-{{.FileExt}}">{{.FileContent}}</pre></td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|
Loading…
Reference in a new issue