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:
parent
a3ebad84a8
commit
6bba4efb3f
3 changed files with 23 additions and 2 deletions
5
.changeset/cuddly-vans-reply.md
Normal file
5
.changeset/cuddly-vans-reply.md
Normal file
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
'@astrojs/markdown-remark': patch
|
||||
---
|
||||
|
||||
Remove `is:raw` from remark Shiki plugin
|
|
@ -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(
|
||||
|
|
16
packages/markdown/remark/test/shiki.js
Normal file
16
packages/markdown/remark/test/shiki.js
Normal 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");
|
||||
});
|
||||
});
|
Loading…
Reference in a new issue