From b0875f8332a8f4a0210c4f0c9f430e4d05803809 Mon Sep 17 00:00:00 2001 From: Sam Saffron Date: Thu, 18 Sep 2014 15:15:42 +1000 Subject: [PATCH] Revert "Revert "FEATURE: fenced code blocks can hint with "pre" or "text""" This reverts commit 4487d6a4c25ba5d3a366e2a8ada489a6a08d67ab. --- .../javascripts/discourse/dialects/code_dialect.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/app/assets/javascripts/discourse/dialects/code_dialect.js b/app/assets/javascripts/discourse/dialects/code_dialect.js index 275b138fe..8ef054529 100644 --- a/app/assets/javascripts/discourse/dialects/code_dialect.js +++ b/app/assets/javascripts/discourse/dialects/code_dialect.js @@ -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) ]]]; + } } });