mirror of
https://github.com/rust-lang/mdBook
synced 2024-12-14 06:42:35 +00:00
Merge pull request #719 from lucasem/patch-1
rustdoc codeblock hash escape
This commit is contained in:
commit
29b3ff14c7
1 changed files with 6 additions and 1 deletions
|
@ -160,9 +160,11 @@ function playpen_text(playpen) {
|
||||||
var lines = code_block.innerHTML.split("\n");
|
var lines = code_block.innerHTML.split("\n");
|
||||||
var first_non_hidden_line = false;
|
var first_non_hidden_line = false;
|
||||||
var lines_hidden = false;
|
var lines_hidden = false;
|
||||||
|
var trimmed_line = "";
|
||||||
|
|
||||||
for (var n = 0; n < lines.length; n++) {
|
for (var n = 0; n < lines.length; n++) {
|
||||||
if (lines[n].trim()[0] == hiding_character) {
|
trimmed_line = lines[n].trim();
|
||||||
|
if (trimmed_line[0] == hiding_character && trimmed_line[1] != hiding_character) {
|
||||||
if (first_non_hidden_line) {
|
if (first_non_hidden_line) {
|
||||||
lines[n] = "<span class=\"hidden\">" + "\n" + lines[n].replace(/(\s*)# ?/, "$1") + "</span>";
|
lines[n] = "<span class=\"hidden\">" + "\n" + lines[n].replace(/(\s*)# ?/, "$1") + "</span>";
|
||||||
}
|
}
|
||||||
|
@ -177,6 +179,9 @@ function playpen_text(playpen) {
|
||||||
else {
|
else {
|
||||||
first_non_hidden_line = true;
|
first_non_hidden_line = true;
|
||||||
}
|
}
|
||||||
|
if (trimmed_line[0] == hiding_character && trimmed_line[1] == hiding_character) {
|
||||||
|
lines[n] = lines[n].replace("##", "#")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
code_block.innerHTML = lines.join("");
|
code_block.innerHTML = lines.join("");
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue