summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Juan Martín Seery <me@juanm04.com> 2022-03-03 14:34:36 -0300
committerGravatar GitHub <noreply@github.com> 2022-03-03 11:34:36 -0600
commitb2c37385f94614232d9a378ef2ef3264d5405cc8 (patch)
tree16409ddfedbcc6d3edbea075cc0ffe69517a5b19
parent519a5d84d141848817846fe9fd5f4d3e838cbc55 (diff)
downloadastro-b2c37385f94614232d9a378ef2ef3264d5405cc8.tar.gz
astro-b2c37385f94614232d9a378ef2ef3264d5405cc8.tar.zst
astro-b2c37385f94614232d9a378ef2ef3264d5405cc8.zip
chore: changed `data-astro-raw` to `is:raw` (#2706)
* chore: changed `data-astro-raw` to `is:raw` * changesets
Diffstat (limited to '')
-rw-r--r--.changeset/thirty-lobsters-ring.md6
-rw-r--r--packages/astro/components/Code.astro4
-rw-r--r--packages/markdown/remark/src/rehype-escape.ts2
-rw-r--r--packages/markdown/remark/src/remark-prism.ts2
-rw-r--r--packages/markdown/remark/src/remark-shiki.ts4
5 files changed, 12 insertions, 6 deletions
diff --git a/.changeset/thirty-lobsters-ring.md b/.changeset/thirty-lobsters-ring.md
new file mode 100644
index 000000000..569ac6be4
--- /dev/null
+++ b/.changeset/thirty-lobsters-ring.md
@@ -0,0 +1,6 @@
+---
+'astro': patch
+'@astrojs/markdown-remark': patch
+---
+
+Changed `data-astro-raw` to `is:raw` internally
diff --git a/packages/astro/components/Code.astro b/packages/astro/components/Code.astro
index 625511774..32c441495 100644
--- a/packages/astro/components/Code.astro
+++ b/packages/astro/components/Code.astro
@@ -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
diff --git a/packages/markdown/remark/src/rehype-escape.ts b/packages/markdown/remark/src/rehype-escape.ts
index 04c931fbf..bb56166be 100644
--- a/packages/markdown/remark/src/rehype-escape.ts
+++ b/packages/markdown/remark/src/rehype-escape.ts
@@ -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;
});
diff --git a/packages/markdown/remark/src/remark-prism.ts b/packages/markdown/remark/src/remark-prism.ts
index cb6d1cd8e..549e09783 100644
--- a/packages/markdown/remark/src/remark-prism.ts
+++ b/packages/markdown/remark/src/remark-prism.ts
@@ -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);
diff --git a/packages/markdown/remark/src/remark-shiki.ts b/packages/markdown/remark/src/remark-shiki.ts
index b482a18fc..5bee7ef6e 100644
--- a/packages/markdown/remark/src/remark-shiki.ts
+++ b/packages/markdown/remark/src/remark-shiki.ts
@@ -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