diff --git a/src/lib/components/chat/Messages/CodeBlock.svelte b/src/lib/components/chat/Messages/CodeBlock.svelte index 5881d109e..fe6c277f1 100644 --- a/src/lib/components/chat/Messages/CodeBlock.svelte +++ b/src/lib/components/chat/Messages/CodeBlock.svelte @@ -4,7 +4,7 @@ import hljs from 'highlight.js'; import 'highlight.js/styles/github-dark.min.css'; import { loadPyodide } from 'pyodide'; - import { tick } from 'svelte'; + import { onMount, tick } from 'svelte'; import PyodideWorker from '$lib/workers/pyodide.worker?worker'; export let id = ''; @@ -12,6 +12,7 @@ export let lang = ''; export let code = ''; + let highlightedCode = null; let executing = false; let stdout = null; @@ -202,60 +203,60 @@ __builtins__.input = input`); }; }; - $: highlightedCode = code ? hljs.highlightAuto(code, hljs.getLanguage(lang)?.aliases).value : ''; + $: if (code) { + highlightedCode = hljs.highlightAuto(code, hljs.getLanguage(lang)?.aliases).value || code; + } -{#if code} -
{@html highlightedCode || code}
-
-
-
- {#if executing}
- {@html highlightedCode || code}
+
+
+
+ {#if executing}
+