diff --git a/kit/preprocessors/mdsvex/index.js b/kit/preprocessors/mdsvex/index.js
index 3e3e0a77..1177a955 100644
--- a/kit/preprocessors/mdsvex/index.js
+++ b/kit/preprocessors/mdsvex/index.js
@@ -338,6 +338,7 @@ const _mdsvexPreprocess = mdsvex({
const base64 = (val) => btoa(encodeURIComponent(val));
const escape = (code) =>
code.replace(/\\/g, "\\\\").replace(/`/g, "\\`").replace(/}/g, "\\}").replace(/\$/g, "\\$");
+ const safeLang = lang && /^[\w-]+$/.test(lang) ? lang : "";
const REGEX_FRAMEWORKS_SPLIT = /\s*===(PT-TF|STRINGAPI-READINSTRUCTION)-SPLIT===\s*/gm;
// Handle mermaid diagrams
@@ -380,6 +381,7 @@ const _mdsvexPreprocess = mdsvex({
code: \`${base64(codeGroup2)}\`,
highlighted: \`${escape(highlightedTf)}\`
}}
+ lang="${safeLang}"
wrap={${wrapCodeBlocks}}
/>`;
} else {
@@ -394,9 +396,10 @@ const _mdsvexPreprocess = mdsvex({
.join("\n");
}
return `
-
{@html highlighted}
+ {@html highlighted}
diff --git a/kit/src/lib/CodeBlockFw.svelte b/kit/src/lib/CodeBlockFw.svelte
index 7c4896fb..16fee660 100644
--- a/kit/src/lib/CodeBlockFw.svelte
+++ b/kit/src/lib/CodeBlockFw.svelte
@@ -5,6 +5,7 @@
export let group1: { id: string; code: string; highlighted: string };
export let group2: { id: string; code: string; highlighted: string };
+ export let lang = "";
export let wrap = false;
const ids = [group1.id, group2.id];
@@ -36,7 +37,8 @@
value={group1.code}
/>
- {:else} @@ -47,7 +49,8 @@ value={group2.code} /> -{@html group1.highlighted}
{/if}{@html group2.highlighted}