FIX: Broken MDTest + Fix for removing leading spaces in a code block
This commit is contained in:
parent
7a85e06119
commit
3d62df51a6
|
@ -29,7 +29,20 @@ Discourse.Dialect.replaceBlock({
|
||||||
|
|
||||||
// Ensure that content in a code block is fully escaped. This way it's not white listed
|
// Ensure that content in a code block is fully escaped. This way it's not white listed
|
||||||
// and we can use HTML and Javascript examples.
|
// and we can use HTML and Javascript examples.
|
||||||
Discourse.Dialect.postProcessTag('code', function (contents) {
|
Discourse.Dialect.on('parseNode', function (event) {
|
||||||
return Handlebars.Utils.escapeExpression(contents.replace(/^ +| +$/g,''));
|
var node = event.node,
|
||||||
});
|
path = event.path;
|
||||||
|
|
||||||
|
if (node[0] === 'code') {
|
||||||
|
var contents = node[node.length-1],
|
||||||
|
regexp;
|
||||||
|
|
||||||
|
if (path && path[path.length-1] && path[path.length-1][0] && path[path.length-1][0] === "pre") {
|
||||||
|
regexp = / +$/g;
|
||||||
|
|
||||||
|
} else {
|
||||||
|
regexp = /^ +| +$/g;
|
||||||
|
}
|
||||||
|
node[node.length-1] = Handlebars.Utils.escapeExpression(contents.replace(regexp,''));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
|
@ -524,7 +524,7 @@ easy to include example HTML source code using Markdown -- just paste
|
||||||
it and indent it, and Markdown will handle the hassle of encoding the
|
it and indent it, and Markdown will handle the hassle of encoding the
|
||||||
ampersands and angle brackets. For example, this:</p>
|
ampersands and angle brackets. For example, this:</p>
|
||||||
|
|
||||||
<pre><code><div class="footer">
|
<pre><code> <div class="footer">
|
||||||
&copy; 2004 Foo Corporation
|
&copy; 2004 Foo Corporation
|
||||||
</div>
|
</div>
|
||||||
</code></pre>
|
</code></pre>
|
||||||
|
|
Loading…
Reference in New Issue