FIX: Markdown bug when a heading preceeded a code block.

This commit is contained in:
Robin Ward 2014-12-29 15:59:23 -05:00
parent 25e5031fb1
commit 13bf8e1e46
2 changed files with 8 additions and 1 deletions

View file

@ -421,7 +421,12 @@ Discourse.Dialect = {
// just give up if there's no stop tag in this or any next block
args.stop.lastIndex = block.length - trailing.length;
if (!args.stop.exec(block) && lastChance()) { return; }
if (leading.length > 0) { result.push(['p'].concat(this.processInline(leading))); }
if (leading.length > 0) {
var parsedLeading = this.processBlock(MD.mk_block(leading), []);
if (parsedLeading && parsedLeading[0]) {
result.push(parsedLeading[0]);
}
}
if (trailing.length > 0) {
next.unshift(MD.mk_block(trailing, block.trailing,
block.lineNumber + countLines(leading) + (match[2] ? match[2].length : 0) - trailing.length));

View file

@ -398,6 +398,8 @@ test("Code Blocks", function() {
cooked(" [quote]test[/quote]",
"<pre><code>[quote]test[/quote]</code></pre>",
"it does not parse other block types in markdown code blocks");
cooked("## a\nb\n```\nc\n```", "<h2>a</h2>\n\n<p><pre><code class=\"lang-auto\">c</code></pre></p>", "it handles headings with code blocks after them.");
});
test("sanitize", function() {