summaryrefslogtreecommitdiff
path: root/packages/markdown/remark/test/entities.test.js
diff options
context:
space:
mode:
authorGravatar hippotastic <6137925+hippotastic@users.noreply.github.com> 2022-08-05 16:23:16 +0200
committerGravatar GitHub <noreply@github.com> 2022-08-05 16:23:16 +0200
commit16034f0dd5b3683e9e022dbd413e85bd18d2b031 (patch)
tree76fbc27c7ffc4366ecf6c63aa34fa3240a57e6f2 /packages/markdown/remark/test/entities.test.js
parent9315ce65ddebbf3c4f54a83dfa30b7d8c5a8534c (diff)
downloadastro-16034f0dd5b3683e9e022dbd413e85bd18d2b031.tar.gz
astro-16034f0dd5b3683e9e022dbd413e85bd18d2b031.tar.zst
astro-16034f0dd5b3683e9e022dbd413e85bd18d2b031.zip
Fix double-escaping of non-highlighted code blocks in Astro-flavored markdown (#4169)
Diffstat (limited to 'packages/markdown/remark/test/entities.test.js')
-rw-r--r--packages/markdown/remark/test/entities.test.js22
1 files changed, 18 insertions, 4 deletions
diff --git a/packages/markdown/remark/test/entities.test.js b/packages/markdown/remark/test/entities.test.js
index a6b5918a5..dff844329 100644
--- a/packages/markdown/remark/test/entities.test.js
+++ b/packages/markdown/remark/test/entities.test.js
@@ -2,11 +2,25 @@ import { renderMarkdown } from '../dist/index.js';
import { expect } from 'chai';
describe('entities', () => {
- const renderAstroMd = (text) => renderMarkdown(text, { isAstroFlavoredMd: false });
-
- it('should not unescape entities', async () => {
- const { code } = await renderAstroMd(`&lt;i&gt;This should NOT be italic&lt;/i&gt;`);
+ it('should not unescape entities in regular Markdown', async () => {
+ const { code } = await renderMarkdown(`&lt;i&gt;This should NOT be italic&lt;/i&gt;`, {
+ isAstroFlavoredMd: false,
+ });
expect(code).to.equal(`<p>&#x3C;i>This should NOT be italic&#x3C;/i></p>`);
});
+
+ it('should not escape entities in code blocks twice in Astro-flavored markdown', async () => {
+ const { code } = await renderMarkdown(
+ `\`\`\`astro\n<h1>{x && x.name || ''}!</h1>\n\`\`\``,
+ {
+ isAstroFlavoredMd: true,
+ syntaxHighlight: false,
+ }
+ );
+
+ expect(code).to.equal(
+ `<pre is:raw><code class="language-astro">&lt;h1&gt;{x &amp;&amp; x.name || ''}!&lt;/h1&gt;\n</code></pre>`
+ );
+ });
});