diff --git a/lib/utils/compile-markdown.js b/lib/utils/compile-markdown.js index cb1b16988..6a2e77726 100644 --- a/lib/utils/compile-markdown.js +++ b/lib/utils/compile-markdown.js @@ -74,13 +74,17 @@ class HBSRenderer extends marked.Renderer { return code.replace(/^
/, '
');
   }
 
-  // Unescape quotes in text, as they may be part of a Handlebars statement
+  // Unescape markdown escaping in general, since it can interfere with
+  // Handlebars templating
   text() {
     let text = super.text.apply(this, arguments);
     if (this.config.targetHandlebars) {
       text = text
-        .replace(/"|"/g, `"`)
-        .replace(/'|'/g, `'`);
+        .replace(/&/g, '&')
+        .replace(/</g, '<')
+        .replace(/>/g, '>')
+        .replace(/"|"/g, '"')
+        .replace(/'|'/g, '\'');
     }
     return text;
   }
diff --git a/tests-node/unit/utils/compile-markdown-test.js b/tests-node/unit/utils/compile-markdown-test.js
index e54a0a997..c4f5666de 100644
--- a/tests-node/unit/utils/compile-markdown-test.js
+++ b/tests-node/unit/utils/compile-markdown-test.js
@@ -37,4 +37,32 @@ QUnit.module('Unit | compile-markdown', function(hooks) {
 
     assert.equal(result, expected);
   });
+
+  test('classic components remain unescaped', function(assert) {
+    let input = stripIndent`
+      {{#foo-bar prop="value" otherProp='value'}}
+
+      {{/foo-bar}}
+    `;
+
+    let result = compileMarkdown(input, { targetHandlebars: true });
+    let expected = stripIndent`
+      

{{#foo-bar prop="value" otherProp='value'}} {{/foo-bar}}

+ `; + + assert.equal(result, expected); + }); + + test('angle bracket contextual components remain unescaped', function(assert) { + let input = stripIndent` + + `; + + let result = compileMarkdown(input, { targetHandlebars: true }); + let expected = stripIndent` +

+ `; + + assert.equal(result, expected); + }); });