diff --git a/app/assets/javascripts/discourse/dialects/dialect.js b/app/assets/javascripts/discourse/dialects/dialect.js index b54011180ab..e80e5e96710 100644 --- a/app/assets/javascripts/discourse/dialects/dialect.js +++ b/app/assets/javascripts/discourse/dialects/dialect.js @@ -188,14 +188,6 @@ function hoistCodeBlocksAndSpans(text) { // /!\ the order is important /!\ - //
...code blocks - text = text.replace(/(\s|^)
([\s\S]*?)<\/pre>/ig, function(_, before, content) { - var hash = md5(content); - hoisted[hash] = escape(showBackslashEscapedCharacters(removeEmptyLines(content))); - return before + "" + hash + ""; - }); - - // fenced code blocks (AKA GitHub code blocks) text = text.replace(/(^\n*|\n)```([a-z0-9\-]*)\n([\s\S]*?)\n```/g, function(_, before, language, content) { var hash = md5(content); @@ -219,6 +211,13 @@ function hoistCodeBlocksAndSpans(text) { return before + " " + hash + "\n"; }); + //...code blocks + text = text.replace(/(\s|^)([\s\S]*?)<\/pre>/ig, function(_, before, content) { + var hash = md5(content); + hoisted[hash] = escape(showBackslashEscapedCharacters(removeEmptyLines(content))); + return before + "" + hash + ""; + }); + // code spans (double & single `) ["``", "`"].forEach(function(delimiter) { var regexp = new RegExp("(^|[^`])" + delimiter + "([^`\\n]+?)" + delimiter + "([^`]|$)", "g");