FIX: hoisting issue with regexp replacement patterns
This commit is contained in:
parent
dce258017f
commit
3954f69514
|
@ -278,7 +278,9 @@ Discourse.Dialect = {
|
||||||
var keys = Object.keys(hoisted);
|
var keys = Object.keys(hoisted);
|
||||||
if (keys.length) {
|
if (keys.length) {
|
||||||
keys.forEach(function(key) {
|
keys.forEach(function(key) {
|
||||||
result = result.replace(new RegExp(key, "g"), hoisted[key]);
|
result = result.replace(new RegExp(key, "g"), function() {
|
||||||
|
return hoisted[key];
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -531,4 +531,8 @@ test("code blocks/spans hoisting", function() {
|
||||||
cooked("```\n\n some code\n```",
|
cooked("```\n\n some code\n```",
|
||||||
"<p><pre><code class=\"lang-auto\"> some code</code></pre></p>",
|
"<p><pre><code class=\"lang-auto\"> some code</code></pre></p>",
|
||||||
"it works when nesting standard markdown code blocks within a fenced code block");
|
"it works when nesting standard markdown code blocks within a fenced code block");
|
||||||
|
|
||||||
|
cooked("`$&`",
|
||||||
|
"<p><code>$&</code></p>",
|
||||||
|
"it works even when hoisting special replacement patterns");
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue