feat: add KaTeX <Tex> component for math typography

This commit is contained in:
2026-05-03 13:15:42 +07:00
parent a0da079500
commit 7c282c3aee
3 changed files with 58 additions and 5 deletions
+26
View File
@@ -0,0 +1,26 @@
<script>
import katex from 'katex';
/**
* @type {{
* math: string;
* display?: boolean;
* ariaLabel?: string;
* }}
*/
let { math, display = false, ariaLabel } = $props();
const html = $derived(
katex.renderToString(math, {
displayMode: display,
throwOnError: false,
output: 'htmlAndMathml',
})
);
</script>
{#if ariaLabel}
<span aria-label={ariaLabel}>{@html html}</span>
{:else}
{@html html}
{/if}