diff --git a/app/assets/javascripts/discourse/dialects/dialect.js b/app/assets/javascripts/discourse/dialects/dialect.js index 9d0cbef8d..e5b904840 100644 --- a/app/assets/javascripts/discourse/dialects/dialect.js +++ b/app/assets/javascripts/discourse/dialects/dialect.js @@ -278,7 +278,9 @@ Discourse.Dialect = { var keys = Object.keys(hoisted); if (keys.length) { keys.forEach(function(key) { - result = result.replace(new RegExp(key, "g"), hoisted[key]); + result = result.replace(new RegExp(key, "g"), function() { + return hoisted[key]; + }); }); } diff --git a/test/javascripts/lib/markdown-test.js.es6 b/test/javascripts/lib/markdown-test.js.es6 index f5859165f..25c2a6901 100644 --- a/test/javascripts/lib/markdown-test.js.es6 +++ b/test/javascripts/lib/markdown-test.js.es6 @@ -531,4 +531,8 @@ test("code blocks/spans hoisting", function() { cooked("```\n\n some code\n```", "

    some code

", "it works when nesting standard markdown code blocks within a fenced code block"); + + cooked("`$&`", + "

$&

", + "it works even when hoisting special replacement patterns"); });