Skip to content

Commit

Permalink
chore: changed data-astro-raw to is:raw (#2706)
Browse files Browse the repository at this point in the history
* chore: changed `data-astro-raw` to `is:raw`

* changesets
  • Loading branch information
JuanM04 authored Mar 3, 2022
1 parent 519a5d8 commit b2c3738
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 6 deletions.
6 changes: 6 additions & 0 deletions .changeset/thirty-lobsters-ring.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'astro': patch
'@astrojs/markdown-remark': patch
---

Changed `data-astro-raw` to `is:raw` internally
4 changes: 2 additions & 2 deletions packages/astro/components/Code.astro
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ const { code, lang = 'plaintext', theme = 'github-dark', wrap = false } = Astro.
/** Replace the shiki class name with a custom astro class name. */
function repairShikiTheme(html: string): string {
// Replace "shiki" class naming with "astro" and add "data-astro-raw".
html = html.replace('<pre class="shiki"', '<pre data-astro-raw class="astro-code"');
// Replace "shiki" class naming with "astro" and add "is:raw".
html = html.replace('<pre class="shiki"', '<pre is:raw class="astro-code"');
// Replace "shiki" css variable naming with "astro".
html = html.replace(/style="(background-)?color: var\(--shiki-/g, 'style="$1color: var(--astro-code-');
// Handle code wrapping
Expand Down
2 changes: 1 addition & 1 deletion packages/markdown/remark/src/rehype-escape.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export default function rehypeEscape(): any {
return function (node: any): any {
return visit(node, 'element', (el) => {
if (el.tagName === 'code' || el.tagName === 'pre') {
el.properties['data-astro-raw'] = true;
el.properties['is:raw'] = true;
}
return el;
});
Expand Down
2 changes: 1 addition & 1 deletion packages/markdown/remark/src/remark-prism.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ function transformer(className: MaybeString) {
if (className) {
classes.push(className);
}
node.value = `<pre class="${classes.join(' ')}"><code data-astro-raw class="${classLanguage}">${html}</code></pre>`;
node.value = `<pre class="${classes.join(' ')}"><code is:raw class="${classLanguage}">${html}</code></pre>`;
return node;
};
return visit(tree, 'code', visitor);
Expand Down
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 @@ -50,8 +50,8 @@ const remarkShiki = async ({ langs = [], theme = 'github-dark', wrap = false }:
visit(tree, 'code', (node) => {
let html = highlighter!.codeToHtml(node.value, { lang: node.lang ?? 'plaintext' });

// Replace "shiki" class naming with "astro" and add "data-astro-raw".
html = html.replace('<pre class="shiki"', '<pre data-astro-raw class="astro-code"');
// Replace "shiki" class naming with "astro" and add "is:raw".
html = html.replace('<pre class="shiki"', '<pre is:raw class="astro-code"');
// Replace "shiki" css variable naming with "astro".
html = html.replace(/style="(background-)?color: var\(--shiki-/g, 'style="$1color: var(--astro-code-');
// Handle code wrapping
Expand Down

0 comments on commit b2c3738

Please sign in to comment.