Support math rendering on MFM (#3260)
This commit is contained in:
26
src/client/app/common/views/components/formula.vue
Normal file
26
src/client/app/common/views/components/formula.vue
Normal file
@ -0,0 +1,26 @@
|
||||
<template>
|
||||
<span v-html="compiledFormula"></span>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import Vue from 'vue';
|
||||
import * as katex from 'katex';
|
||||
|
||||
export default Vue.extend({
|
||||
props: {
|
||||
formula: {
|
||||
type: String,
|
||||
required: true
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
compiledFormula(): any {
|
||||
return katex.renderToString(this.formula);
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<style>
|
||||
@import "../../../../../../node_modules/katex/dist/katex.min.css";
|
||||
</style>
|
@ -1,5 +1,6 @@
|
||||
import Vue, { VNode } from 'vue';
|
||||
import { length } from 'stringz';
|
||||
import MkFormula from './formula.vue';
|
||||
import parse from '../../../../../mfm/parse';
|
||||
import getAcct from '../../../../../misc/acct/render';
|
||||
import MkUrl from './url.vue';
|
||||
@ -199,6 +200,14 @@ export default Vue.component('misskey-flavored-markdown', {
|
||||
})];
|
||||
}
|
||||
|
||||
case 'math': {
|
||||
return [createElement(MkFormula, {
|
||||
props: {
|
||||
formula: token.formula
|
||||
}
|
||||
})];
|
||||
}
|
||||
|
||||
case 'search': {
|
||||
return [createElement(MkGoogle, {
|
||||
props: {
|
||||
|
Reference in New Issue
Block a user