diff options
author | 2023-10-04 12:23:58 +0200 | |
---|---|---|
committer | 2023-10-04 18:23:58 +0800 | |
commit | 21f4826576c2c812a1604e18717799da3470decd (patch) | |
tree | decf4d6b5f2f939f8e1d2df509ebdd143d1695d2 | |
parent | 71618f4074244ec203d154788b4aff29fce094dd (diff) | |
download | astro-21f4826576c2c812a1604e18717799da3470decd.tar.gz astro-21f4826576c2c812a1604e18717799da3470decd.tar.zst astro-21f4826576c2c812a1604e18717799da3470decd.zip |
Fixes: Shiki syntax highlighting adds is:raw attribute to the HTML output (#8715)
Co-authored-by: Emanuele Stoppa <my.burning@gmail.com>
-rw-r--r-- | .changeset/cuddly-vans-reply.md | 5 | ||||
-rw-r--r-- | packages/markdown/remark/src/remark-shiki.ts | 4 | ||||
-rw-r--r-- | packages/markdown/remark/test/shiki.js | 16 |
3 files changed, 23 insertions, 2 deletions
diff --git a/.changeset/cuddly-vans-reply.md b/.changeset/cuddly-vans-reply.md new file mode 100644 index 000000000..702aecc22 --- /dev/null +++ b/.changeset/cuddly-vans-reply.md @@ -0,0 +1,5 @@ +--- +'@astrojs/markdown-remark': patch +--- + +Remove `is:raw` from remark Shiki plugin diff --git a/packages/markdown/remark/src/remark-shiki.ts b/packages/markdown/remark/src/remark-shiki.ts index 6cd3861e5..58ed16369 100644 --- a/packages/markdown/remark/src/remark-shiki.ts +++ b/packages/markdown/remark/src/remark-shiki.ts @@ -76,8 +76,8 @@ export function remarkShiki({ // It would become this before hitting our regexes: // <span class="line" - // Replace "shiki" class naming with "astro" and add "is:raw". - html = html.replace(/<pre class="(.*?)shiki(.*?)"/, `<pre is:raw class="$1astro-code$2"`); + // Replace "shiki" class naming with "astro". + html = html.replace(/<pre class="(.*?)shiki(.*?)"/, `<pre class="$1astro-code$2"`); // Add "user-select: none;" for "+"/"-" diff symbols if (node.lang === 'diff') { html = html.replace( diff --git a/packages/markdown/remark/test/shiki.js b/packages/markdown/remark/test/shiki.js new file mode 100644 index 000000000..5077623e8 --- /dev/null +++ b/packages/markdown/remark/test/shiki.js @@ -0,0 +1,16 @@ +import { createMarkdownProcessor } from '../dist/index.js'; +import chai from 'chai'; + +describe('shiki syntax highlighting', async () => { + const processor = await createMarkdownProcessor(); + + it('does not add is:raw to the output', async () => { + const { + code, + } = await processor.render('```\ntest\n```'); + + chai + .expect(code) + .not.to.contain("is:raw"); + }); +});
\ No newline at end of file |