Fixes: Shiki syntax highlighting adds is:raw attribute to the HTML output (#8715)

Co-authored-by: Emanuele Stoppa <my.burning@gmail.com>
This commit is contained in:
Chris 2023-10-04 12:23:58 +02:00 committed by Martin Trapp
parent a3ebad84a8
commit 6bba4efb3f
3 changed files with 23 additions and 2 deletions

View file

@ -0,0 +1,5 @@
---
'@astrojs/markdown-remark': patch
---
Remove `is:raw` from remark Shiki plugin

View file

@ -76,8 +76,8 @@ export function remarkShiki({
// It would become this before hitting our regexes:
// &lt;span class=&quot;line&quot;
// 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(

View file

@ -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");
});
});