diff options
author | 2022-06-20 19:09:35 +0000 | |
---|---|---|
committer | 2022-06-20 19:09:35 +0000 | |
commit | 48e67fe05398dc4b1fca12db36c1b37bb341277a (patch) | |
tree | 3ddc969e8ed14fe60589200c085f25832f135005 /packages/markdown/remark/test | |
parent | 509b4f122fc529571492330b53b058114717604d (diff) | |
download | astro-48e67fe05398dc4b1fca12db36c1b37bb341277a.tar.gz astro-48e67fe05398dc4b1fca12db36c1b37bb341277a.tar.zst astro-48e67fe05398dc4b1fca12db36c1b37bb341277a.zip |
Encode ampersands in markdown code blocks (#3630)
* encode ampersands in markdown code blocks
* chore: add changeset
* nit: fixing test case description
Diffstat (limited to 'packages/markdown/remark/test')
-rw-r--r-- | packages/markdown/remark/test/expressions.test.js | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/packages/markdown/remark/test/expressions.test.js b/packages/markdown/remark/test/expressions.test.js index fdf578923..0361e1df8 100644 --- a/packages/markdown/remark/test/expressions.test.js +++ b/packages/markdown/remark/test/expressions.test.js @@ -1,5 +1,5 @@ import { renderMarkdown } from '../dist/index.js'; -import chai from 'chai'; +import chai, { expect } from 'chai'; describe('expressions', () => { it('should be able to serialize bare expression', async () => { @@ -71,6 +71,33 @@ describe('expressions', () => { ); }); + it('should be able to encode ampersand characters in code blocks', async () => { + const { code } = await renderMarkdown( + 'The ampersand in ` ` must be encoded in code blocks.', + {} + ); + + chai + .expect(code) + .to.equal( + '<p>The ampersand in <code is:raw>&nbsp;</code> must be encoded in code blocks.</p>' + ) + }); + + it('should be able to encode ampersand characters in fenced code blocks', async () => { + const { code } = await renderMarkdown(` + \`\`\`md + The ampersand in \` \` must be encoded in code blocks. + \`\`\` + `); + + chai + .expect(code) + .to.match( + /^<pre is:raw.*<code>.*The ampersand in `&nbsp;`/ + ); + }) + it('should be able to serialize function expression', async () => { const { code } = await renderMarkdown( `{frontmatter.list.map(item => <p id={item}>{item}</p>)}`, |