2020-01-29 13:37:25 -06:00
|
|
|
|
2018-11-16 03:31:25 -06:00
|
|
|
<template>
|
2019-01-25 08:08:06 -06:00
|
|
|
<div v-if="block" v-html="compiledFormula"></div>
|
|
|
|
<span v-else v-html="compiledFormula"></span>
|
2018-11-16 03:31:25 -06:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
|
|
|
import Vue from 'vue';
|
|
|
|
import * as katex from 'katex';
|
|
|
|
export default Vue.extend({
|
|
|
|
props: {
|
|
|
|
formula: {
|
|
|
|
type: String,
|
|
|
|
required: true
|
2019-01-25 08:08:06 -06:00
|
|
|
},
|
|
|
|
block: {
|
|
|
|
type: Boolean,
|
|
|
|
required: true
|
2018-11-16 03:31:25 -06:00
|
|
|
}
|
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
compiledFormula(): any {
|
2018-12-27 06:07:44 -06:00
|
|
|
return katex.renderToString(this.formula, {
|
2018-12-27 06:09:03 -06:00
|
|
|
throwOnError: false
|
2018-12-27 06:07:44 -06:00
|
|
|
} as any);
|
2018-11-16 03:31:25 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style>
|
2020-01-29 13:37:25 -06:00
|
|
|
@import "../../../node_modules/katex/dist/katex.min.css";
|
2018-11-16 03:31:25 -06:00
|
|
|
</style>
|