From d8d849ee84515b3f88806dacbd2b2b2a9e529b5d Mon Sep 17 00:00:00 2001 From: Sam Date: Fri, 31 Jul 2015 18:27:23 +1000 Subject: [PATCH] hoist pre blocks last --- .../javascripts/discourse/dialects/dialect.js | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) 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");