Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 2 commits into from
Oct 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/cuddly-vans-reply.md
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
16 changes: 16 additions & 0 deletions packages/markdown/remark/test/shiki.js
Original file line number Diff line number Diff line change
@@ -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");
});
});