Commit f342f8ad authored by Timothy J. Baek's avatar Timothy J. Baek
Browse files

refac: code highlight optimisation

parent deb4e360
...@@ -203,8 +203,18 @@ __builtins__.input = input`); ...@@ -203,8 +203,18 @@ __builtins__.input = input`);
}; };
}; };
let debounceTimeout;
$: if (code) { $: if (code) {
highlightedCode = hljs.highlightAuto(code, hljs.getLanguage(lang)?.aliases).value || code; // Function to perform the code highlighting
const highlightCode = () => {
highlightedCode = hljs.highlightAuto(code, hljs.getLanguage(lang)?.aliases).value || code;
};
// Clear the previous timeout if it exists
clearTimeout(debounceTimeout);
// Set a new timeout to debounce the code highlighting
debounceTimeout = setTimeout(highlightCode, 10);
} }
</script> </script>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment