fix: 🐛 fix code blocks rendering as "undefined" for unregistered languages
This commit is contained in:
parent
65dd18b7cd
commit
68660543d7
1029
webapp/package-lock.json
generated
1029
webapp/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -13,20 +13,15 @@
|
|||||||
|
|
||||||
onMount(() => {
|
onMount(() => {
|
||||||
if (browser) {
|
if (browser) {
|
||||||
highlighted = hljs.highlight(text, { language: lang }).value;
|
if (hljs.getLanguage(lang) !== undefined) {
|
||||||
|
highlighted = hljs.highlight(text, { language: lang }).value;
|
||||||
|
} else {
|
||||||
|
highlighted = text;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<svelte:head>
|
|
||||||
<!-- <link
|
|
||||||
rel="stylesheet"
|
|
||||||
href="//cdnjs.cloudflare.com/ajax/libs/highlight.js/11.6.0/styles/github-dark.min.css"
|
|
||||||
/> -->
|
|
||||||
</svelte:head>
|
|
||||||
|
|
||||||
<div class="">
|
<div class="">
|
||||||
<!-- <pre class="language-{lang}"><code>{text}</code></pre> -->
|
|
||||||
|
|
||||||
<pre class="language-{lang}"><code>{@html highlighted}</code></pre>
|
<pre class="language-{lang}"><code>{@html highlighted}</code></pre>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
Reference in New Issue
Block a user