From dbc608a6c8e2d9d5f19c7865eeaf92400750ea98 Mon Sep 17 00:00:00 2001 From: naskya Date: Sat, 29 Apr 2023 14:01:24 +0000 Subject: [PATCH] fix: centering block math (#9946) Similar to `inlineCode` and `blockCode`, MFM provides two types of formula syntax, `mathInline` and `mathBlock` (I'm curious why these aren't called `inlineMath`/`blockMath`, but oh well) Other platforms, like GitHub, **Math**todon, my blog, etc., also support these two types of formula representation, and math blocks are centered on (maybe) all such platforms. ![](https://cdn.discordapp.com/attachments/823878222897741868/1101837026304720997/2023-04-29_201943.png) But Calckey (Misskey v12) don't center math blocks. I'd say this is a bug, and this makes `blockMath` useless (it's just `inlineMath` in a new line). ![](https://cdn.discordapp.com/attachments/823878222897741868/1101837026027917342/2023-04-29_202008.png) So I fixed this. ![](https://cdn.discordapp.com/attachments/823878222897741868/1101837183574355978/2023-04-29_202854.png) Co-authored-by: naskya Reviewed-on: https://codeberg.org/calckey/calckey/pulls/9946 Co-authored-by: naskya Co-committed-by: naskya --- packages/client/src/components/MkFormulaCore.vue | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/client/src/components/MkFormulaCore.vue b/packages/client/src/components/MkFormulaCore.vue index 5675dbfa0..2db4c7d00 100644 --- a/packages/client/src/components/MkFormulaCore.vue +++ b/packages/client/src/components/MkFormulaCore.vue @@ -20,9 +20,12 @@ export default defineComponent({ }, computed: { compiledFormula(): any { - return katex.renderToString(this.formula, { + const katexString = katex.renderToString(this.formula, { throwOnError: false, } as any); + return this.block + ? `
${katexString}
` + : katexString; }, }, });