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.
This commit is contained in:
Robin Ward 2015-08-24 16:29:58 -04:00
parent 99edcddafb
commit f2db4bfcf3
2 changed files with 6 additions and 6 deletions

View File

@ -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)]];
}
});

View File

@ -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 = {