mirror of
https://github.com/discourse/discourse.git
synced 2024-11-24 01:22:36 +08:00
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:
parent
99edcddafb
commit
f2db4bfcf3
|
@ -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)]];
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -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 = {
|
||||
|
|
Loading…
Reference in New Issue
Block a user