mirror of
https://github.com/open-webui/open-webui.git
synced 2025-12-11 20:05:19 +00:00
22 lines
575 B
Svelte
22 lines
575 B
Svelte
<script lang="ts">
|
|
import type { renderToString as katexRenderToString } from 'katex';
|
|
import { onMount } from 'svelte';
|
|
|
|
export let content: string;
|
|
export let displayMode: boolean = false;
|
|
|
|
let renderToString: typeof katexRenderToString | null = null;
|
|
|
|
onMount(async () => {
|
|
const [katex] = await Promise.all([
|
|
import('katex'),
|
|
import('katex/contrib/mhchem'),
|
|
import('katex/dist/katex.min.css')
|
|
]);
|
|
renderToString = katex.renderToString;
|
|
});
|
|
</script>
|
|
|
|
{#if renderToString}
|
|
{@html renderToString(content, { displayMode, throwOnError: false })}
|
|
{/if}
|