mirror of
https://github.com/tiennm99/mathmax.git
synced 2026-09-10 04:19:56 +00:00
feat: add KaTeX <Tex> component for math typography
This commit is contained in:
@@ -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}
|
||||
Reference in New Issue
Block a user