From f2db4bfcf3ee6dc024ef1bee91acf66049753501 Mon Sep 17 00:00:00 2001 From: Robin Ward Date: Mon, 24 Aug 2015 16:29:58 -0400 Subject: [PATCH] FIX: Conflict in dialect method names broke code formatting Sometimes newlines were being stripped from code contents due to the table formatting using the same method name. In the future we will be rewriting dialects to prevent this. --- app/assets/javascripts/discourse/dialects/code_dialect.js | 8 ++++---- .../javascripts/discourse/dialects/table_dialect.js | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/app/assets/javascripts/discourse/dialects/code_dialect.js b/app/assets/javascripts/discourse/dialects/code_dialect.js index f6260d83180..e7322a4abeb 100644 --- a/app/assets/javascripts/discourse/dialects/code_dialect.js +++ b/app/assets/javascripts/discourse/dialects/code_dialect.js @@ -21,7 +21,7 @@ if (Discourse.SiteSettings && Discourse.SiteSettings.highlighted_languages) { var textCodeClasses = ["text", "pre", "plain"]; -function flattenBlocks(blocks) { +function codeFlattenBlocks(blocks) { var result = ""; blocks.forEach(function(b) { result += b; @@ -42,9 +42,9 @@ Discourse.Dialect.replaceBlock({ } if (textCodeClasses.indexOf(matches[1]) !== -1) { - return ['p', ['pre', ['code', {'class': 'lang-nohighlight'}, flattenBlocks(blockContents) ]]]; + return ['p', ['pre', ['code', {'class': 'lang-nohighlight'}, codeFlattenBlocks(blockContents) ]]]; } else { - return ['p', ['pre', ['code', {'class': 'lang-' + klass}, flattenBlocks(blockContents) ]]]; + return ['p', ['pre', ['code', {'class': 'lang-' + klass}, codeFlattenBlocks(blockContents) ]]]; } } }); @@ -56,7 +56,7 @@ Discourse.Dialect.replaceBlock({ skipIfTradtionalLinebreaks: true, emitter: function(blockContents) { - return ['p', ['pre', flattenBlocks(blockContents)]]; + return ['p', ['pre', codeFlattenBlocks(blockContents)]]; } }); diff --git a/app/assets/javascripts/discourse/dialects/table_dialect.js b/app/assets/javascripts/discourse/dialects/table_dialect.js index ad1bb375dff..da9b2c2fcf4 100644 --- a/app/assets/javascripts/discourse/dialects/table_dialect.js +++ b/app/assets/javascripts/discourse/dialects/table_dialect.js @@ -1,4 +1,4 @@ -var flattenBlocks = function(blocks) { +var tableFlattenBlocks = function(blocks) { var result = ""; blocks.forEach(function(b) { result += b; @@ -19,7 +19,7 @@ var emitter = function(contents) { window.html4.ELEMENTS.th = 1; window.html4.ELEMENTS.tr = 1; } - return ['table', {"class": "md-table"}, flattenBlocks.apply(this, [contents])]; + return ['table', {"class": "md-table"}, tableFlattenBlocks.apply(this, [contents])]; }; var tableBlock = {