Fixed language picker bug in viewer

This commit is contained in:
Maurice 2024-02-05 16:34:29 +01:00
parent 049a1b0125
commit 8b3c78cb84

@ -6,23 +6,22 @@
export let language: string | undefined;
let displayCode: string | undefined;
let displayLanguage: string | undefined;
let showAlert = false;
let initial = true;
$: if(code) {
highlight();
initial = false;
}
$: if(language) {
if(initial || !code) {
highlight();
}
$: if(language !== displayLanguage) {
highlight();
}
function highlight() {
if(language) {
const res = hljs.highlight(language!, code!);
const res = hljs.highlight(code!, {
language
});
if(!res.errorRaised) {
displayCode = res.value;
}
@ -33,6 +32,7 @@
language = res.language;
}
}
displayLanguage = language;
}
async function copy() {