Skip to content

Commit 80f0225

Browse files
fix: remove is:raw from rehype-prism plugin (#15297)
Co-authored-by: Florian Lefebvre <contact@florian-lefebvre.dev>
1 parent 6fccf85 commit 80f0225

File tree

3 files changed

+20
-1
lines changed

3 files changed

+20
-1
lines changed

.changeset/flat-symbols-arrive.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@astrojs/markdown-remark': patch
3+
---
4+
5+
Fixes a case where code blocks generated by prism would include the `is:raw` attribute in the final output

packages/markdown/remark/src/rehype-prism.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export const rehypePrism: Plugin<[string[]?], Root> = (excludeLangs) => {
1111
let { html, classLanguage } = runHighlighterWithAstro(language, code);
1212

1313
return Promise.resolve(
14-
`<pre class="${classLanguage}" data-language="${language}"><code is:raw class="${classLanguage}">${html}</code></pre>`,
14+
`<pre class="${classLanguage}" data-language="${language}"><code class="${classLanguage}">${html}</code></pre>`,
1515
);
1616
},
1717
excludeLangs,
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import assert from 'node:assert/strict';
2+
import { describe, it } from 'node:test';
3+
import { createMarkdownProcessor } from '../dist/index.js';
4+
5+
describe('prism syntax highlighting', () => {
6+
it('does not add is:raw to the output', async () => {
7+
const processor = await createMarkdownProcessor({
8+
syntaxHighlight: 'prism',
9+
});
10+
const { code } = await processor.render('```\ntest\n```');
11+
12+
assert.ok(!code.includes('is:raw'));
13+
});
14+
});

0 commit comments

Comments
 (0)