diff --git a/app/assets/javascripts/discourse/dialects/github_code_dialect.js b/app/assets/javascripts/discourse/dialects/github_code_dialect.js index 425194dfb1a..ffa747e5843 100644 --- a/app/assets/javascripts/discourse/dialects/github_code_dialect.js +++ b/app/assets/javascripts/discourse/dialects/github_code_dialect.js @@ -42,15 +42,19 @@ Discourse.Dialect.on("register", function(event) { if (m[2]) { next.unshift(MD.mk_block(m[2], null, lineNumber + 1)); } + lineNumber++; while (next.length > 0) { var b = next.shift(), - n = b.match(/([^`]*)```([^`]*)/m), - diff = ((typeof b.lineNumber === "undefined") ? lineNumber : b.lineNumber) - lineNumber; + blockLine = b.lineNumber, + diff = ((typeof blockLine === "undefined") ? lineNumber : blockLine) - lineNumber; + + b = b.replace(/ {2}\n/g, "\n"); + var n = b.match(/([^`]*)```([^`]*)/m); - lineNumber = b.lineNumber; for (var i=1; i
a\nb\nc\n\nd

", + "it treats new lines properly"); + cooked("```\ntest\n```", "

test

", "it supports basic code blocks");