mirror of
https://github.com/discourse/discourse.git
synced 2024-11-27 23:16:20 +08:00
Revert "Revert "FEATURE: fenced code blocks can hint with "pre" or "text"""
This reverts commit 4487d6a4c2
.
This commit is contained in:
parent
d6a562658a
commit
b0875f8332
|
@ -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) {
|
||||
|
@ -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) ]]];
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user