From 914f0c351224896db1a205c6b20c03cfdd67bce3 Mon Sep 17 00:00:00 2001 From: Robin Ward Date: Fri, 4 Jul 2014 15:12:30 -0400 Subject: [PATCH] FIX: Don't surround oneboxes by paragraphs --- app/assets/javascripts/discourse/dialects/dialect.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/app/assets/javascripts/discourse/dialects/dialect.js b/app/assets/javascripts/discourse/dialects/dialect.js index 32c1fed30dd..d8fd7298dec 100644 --- a/app/assets/javascripts/discourse/dialects/dialect.js +++ b/app/assets/javascripts/discourse/dialects/dialect.js @@ -101,6 +101,14 @@ function parseTree(tree, path, insideCounts) { insideCounts[tagName] = insideCounts[tagName] - 1; } + + // If raw nodes are in paragraphs, pull them up + if (tree.length === 2 && tree[0] === 'p' && tree[1] instanceof Array && tree[1][0] === "__RAW") { + var text = tree[1][1]; + tree[0] = "__RAW"; + tree[1] = text; + } + path.pop(); } return tree; @@ -149,9 +157,6 @@ Discourse.Dialect = { var tree = parser.toHTMLTree(text, 'Discourse'), result = parser.renderJsonML(parseTree(tree)); - // This feature is largely for MDTest. We prefer to strip comments - // in Discourse - if (opts.sanitize) { result = Discourse.Markdown.sanitize(result); } else if (opts.sanitizerFunction) {