Hides rust code lines prepended with #

This commit is contained in:
Mathieu David 2015-12-29 12:26:32 +01:00
parent d6d0979ecf
commit 0620ef1f47
3 changed files with 16 additions and 2 deletions

View File

@ -9,6 +9,9 @@ body {
.right { .right {
float: right; float: right;
} }
.hidden {
display: none;
}
h2, h2,
h3 { h3 {
margin-top: 2.5em; margin-top: 2.5em;

View File

@ -119,13 +119,20 @@ $( document ).ready(function() {
$("code.language-rust").each(function(i, block){ $("code.language-rust").each(function(i, block){
var lines = $(this).html().split("\n"); var lines = $(this).html().split("\n");
var first_non_hidden_line = false;
for(var n = 0; n < lines.length; n++){ for(var n = 0; n < lines.length; n++){
if($.trim(lines[n])[0] == hiding_character){ if($.trim(lines[n])[0] == hiding_character){
lines[n] = "<span class=\"hidden\">" + lines[n] + "</span>" lines[n] = "<span class=\"hidden\">" + lines[n] + "</span>";
}
else if(first_non_hidden_line) {
lines[n] = "\n" + lines[n];
}
else {
first_non_hidden_line = true;
} }
} }
$(this).html(lines.join()); $(this).html(lines.join(""));
}); });

View File

@ -11,4 +11,8 @@ html, body {
float: right float: right
} }
.hidden {
display: none;
}
h2, h3 { margin-top: 2.5em } h2, h3 { margin-top: 2.5em }