Skip to content

Commit

Permalink
Fixes: Shiki syntax highlighting adds is:raw attribute to the HTML ou…
Browse files Browse the repository at this point in the history
…tput (#8715)

Co-authored-by: Emanuele Stoppa <my.burning@gmail.com>
  • Loading branch information
cprass and ematipico committed Oct 4, 2023
1 parent 71618f4 commit 21f4826
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/cuddly-vans-reply.md
@@ -0,0 +1,5 @@
---
'@astrojs/markdown-remark': patch
---

Remove `is:raw` from remark Shiki plugin
4 changes: 2 additions & 2 deletions packages/markdown/remark/src/remark-shiki.ts
Expand Up @@ -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(
Expand Down
16 changes: 16 additions & 0 deletions 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");
});
});

0 comments on commit 21f4826

Please sign in to comment.