diff --git a/app/assets/javascripts/discourse/dialects/dialect.js b/app/assets/javascripts/discourse/dialects/dialect.js index 749b289fced..07ebc7947d2 100644 --- a/app/assets/javascripts/discourse/dialects/dialect.js +++ b/app/assets/javascripts/discourse/dialects/dialect.js @@ -462,7 +462,7 @@ Discourse.Dialect = { before = currentBlock.slice(0, actualEndPos).replace(/\n*$/, ""), after = currentBlock.slice(actualEndPos + stopLen).replace(/^\n*/, ""); if (before.length > 0) contentBlocks.push(MD.mk_block(before, "", currentBlock.lineNumber)); - if (after.length > 0) next.unshift(MD.mk_block(after, "", currentBlock.lineNumber + countLines(before))); + if (after.length > 0) next.unshift(MD.mk_block(after, currentBlock.trailing, currentBlock.lineNumber + countLines(before))); var emitterResult = args.emitter.call(this, contentBlocks, match, dialect.options); if (emitterResult) { result.push(emitterResult); } diff --git a/test/javascripts/lib/markdown-test.js.es6 b/test/javascripts/lib/markdown-test.js.es6 index 981d4ecebb9..067930e7ddc 100644 --- a/test/javascripts/lib/markdown-test.js.es6 +++ b/test/javascripts/lib/markdown-test.js.es6 @@ -371,6 +371,10 @@ test("Code Blocks", function() { cooked("``` foo bar ```", "

foo bar

", "it tolerates misuse of code block tags as inline code"); + + cooked("```\nline1\n```\n```\nline2\n\nline3\n```", + "

line1

\n\n

line2\n\nline3

", + "it does not consume next block's trailing newlines"); }); test("sanitize", function() {