Skip to content

Commit

Permalink
Revert "Revert "FEATURE: fenced code blocks can hint with "pre" or "t…
Browse files Browse the repository at this point in the history
…ext"""

This reverts commit 4487d6a.
  • Loading branch information
SamSaffron committed Sep 18, 2014
1 parent d6a5626 commit b0875f8
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion app/assets/javascripts/discourse/dialects/code_dialect.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ var acceptableCodeClasses =
"profile", "python", "r", "rib", "rsl", "ruby", "rust", "scala", "smalltalk", "sql", "tex", "text",
"vala", "vbscript", "vhdl"];

var textCodeClasses = ["text", "pre"];

function flattenBlocks(blocks) {
var result = "";
blocks.forEach(function(b) {
Expand All @@ -28,7 +30,12 @@ Discourse.Dialect.replaceBlock({
if (matches[1] && acceptableCodeClasses.indexOf(matches[1]) !== -1) {
klass = matches[1];
}
return ['p', ['pre', ['code', {'class': klass}, flattenBlocks(blockContents) ]]];

if (textCodeClasses.indexOf(matches[1]) !== -1) {
return ['p', ['pre', ['code', flattenBlocks(blockContents) ]]];
} else {
return ['p', ['pre', ['code', {'class': klass}, flattenBlocks(blockContents) ]]];
}
}
});

Expand Down

0 comments on commit b0875f8

Please sign in to comment.