summaryrefslogtreecommitdiff
path: root/packages/frontend/src/components/SkFormula.vue
blob: 6faf36da55778c3fb4e723f8a75261b1f7e473e3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
<!--
SPDX-FileCopyrightText: dakkar, MoshiBar, and other Sharkey contributors
SPDX-License-Identifier: AGPL-3.0-only
-->

<template>
<div v-if="block" :class="$style.block" v-html="renderedFormula"></div>
<span v-else v-html="renderedFormula"></span>
</template>

<script lang="ts" setup>
import { computed } from 'vue';
import katex from 'katex';
import 'katex/dist/katex.min.css';

const props = defineProps<{
		formula: string;
		block: boolean;
	}>();

const renderedFormula = computed(() =>
	katex.renderToString(props.formula, {
		throwOnError: false,
		trust: false,
		displayMode: props.block,
	}));
</script>

<style lang="scss" module>
	.block {
		text-align: center;
	}
</style>