FIX: Code blocks were trimming leading spaces sometimes when they should have only

trimmed trailing spaces.
This commit is contained in:
Robin Ward 2013-08-24 13:24:27 -04:00
parent 093ead7855
commit 5e286443a8
2 changed files with 5 additions and 1 deletions

View File

@ -61,7 +61,7 @@ Discourse.Dialect.on("register", function(event) {
next.unshift(MD.mk_block(n[2]));
}
codeContents.push(n[1].trim());
codeContents.push(n[1].replace(/\s+$/, ""));
break;
} else {
codeContents.push(b);

View File

@ -217,6 +217,10 @@ test("Code Blocks", function() {
cooked(" ```\n hello\n ```",
"<pre><code>&#x60;&#x60;&#x60;\nhello\n&#x60;&#x60;&#x60;</code></pre>",
"only detect ``` at the begining of lines");
cooked("```ruby\ndef self.parse(text)\n\n text\nend\n```",
"<p><pre><code class=\"ruby\">def self.parse(text)\n\n text\nend</code></pre></p>",
"it allows leading spaces on lines in a code block.");
});
test("SanitizeHTML", function() {