diff options
author | 2022-06-20 17:12:42 +0000 | |
---|---|---|
committer | 2022-06-20 17:12:42 +0000 | |
commit | 80c71c7c56d15dc05ec0c5a848130aad222d7d51 (patch) | |
tree | 9b1c74594b3f9f04b97b93aa100025d454e50f17 /packages/markdown/remark/test/expressions.test.js | |
parent | 6523591a8aaefa8e4115be519b9a996f5f9906b0 (diff) | |
download | astro-80c71c7c56d15dc05ec0c5a848130aad222d7d51.tar.gz astro-80c71c7c56d15dc05ec0c5a848130aad222d7d51.tar.zst astro-80c71c7c56d15dc05ec0c5a848130aad222d7d51.zip |
Fixes rendering of HTML comments inside markdown code blocks (#3638)
* JS comment wrappers should be removed from HTML comments in code blocks
* chore: add changeset
Diffstat (limited to 'packages/markdown/remark/test/expressions.test.js')
-rw-r--r-- | packages/markdown/remark/test/expressions.test.js | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/packages/markdown/remark/test/expressions.test.js b/packages/markdown/remark/test/expressions.test.js index 2963ff7f1..12ddc1f48 100644 --- a/packages/markdown/remark/test/expressions.test.js +++ b/packages/markdown/remark/test/expressions.test.js @@ -79,4 +79,24 @@ describe('expressions', () => { chai.expect(code).to.equal(`{frontmatter.list.map(item => <p id={item}>{item}</p>)}`); }); + + it('should unwrap HTML comments in inline code blocks', async () => { + const { code } = await renderMarkdown( + `\`{/*<!-- HTML comment -->*/}\`` + ); + + chai.expect(code).to.equal('<p><code is:raw><!-- HTML comment --></code></p>'); + }); + + it('should unwrap HTML comments in code fences', async () => { + const { code } = await renderMarkdown( + ` + \`\`\` + <!-- HTML comment --> + \`\`\` + ` + ); + + chai.expect(code).to.match(/(?<!{\/\*)<!-- HTML comment -->(?!\*\/})/); + }); }); |