2018-11-16 10:31:25 +01:00
|
|
|
<template>
|
2023-04-08 02:01:42 +02:00
|
|
|
<div v-if="block" v-html="compiledFormula"></div>
|
|
|
|
<span v-else v-html="compiledFormula"></span>
|
2018-11-16 10:31:25 +01:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
2023-04-08 02:01:42 +02:00
|
|
|
import { defineComponent } from "vue";
|
|
|
|
import katex from "katex";
|
2020-10-17 13:12:00 +02:00
|
|
|
|
|
|
|
export default defineComponent({
|
2018-11-16 10:31:25 +01:00
|
|
|
props: {
|
|
|
|
formula: {
|
|
|
|
type: String,
|
2023-04-08 02:01:42 +02:00
|
|
|
required: true,
|
2019-01-25 15:08:06 +01:00
|
|
|
},
|
|
|
|
block: {
|
|
|
|
type: Boolean,
|
2023-04-08 02:01:42 +02:00
|
|
|
required: true,
|
|
|
|
},
|
2018-11-16 10:31:25 +01:00
|
|
|
},
|
|
|
|
computed: {
|
2024-04-11 18:20:51 +02:00
|
|
|
compiledFormula() {
|
2024-04-13 12:46:31 +02:00
|
|
|
return katex.renderToString(this.formula, {
|
2023-04-08 02:01:42 +02:00
|
|
|
throwOnError: false,
|
2024-04-13 12:46:31 +02:00
|
|
|
displayMode: this.block,
|
2024-04-11 18:20:51 +02:00
|
|
|
});
|
2023-04-08 02:01:42 +02:00
|
|
|
},
|
|
|
|
},
|
2018-11-16 10:31:25 +01:00
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style>
|
2021-11-11 18:02:25 +01:00
|
|
|
@import "../../node_modules/katex/dist/katex.min.css";
|
2018-11-16 10:31:25 +01:00
|
|
|
</style>
|