anki/ts/editable/Mathjax.svelte
2021-09-15 13:32:31 +02:00

16 lines
471 B
Svelte

<!--
Copyright: Ankitects Pty Ltd and contributors
License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
-->
<script lang="ts">
import { convertMathjax } from "./mathjax";
export let mathjax: string;
export let type: "inline" | "block" | "chemistry";
$: delimiters = type === "inline" ? ["\\[", "\\]"] : ["\\(", "\\)"];
$: converted = convertMathjax(`${delimiters[0]}${mathjax}${delimiters[1]}`);
</script>
{@html converted}