Support math rendering on MFM (#3260)

This commit is contained in:
Aya Morisawa
2018-11-16 17:03:52 +09:00
committed by syuilo
parent d2385a0e52
commit ad84901f39
7 changed files with 75 additions and 0 deletions

View File

@@ -0,0 +1,20 @@
/**
* Math
*/
export type TextElementMath = {
type: 'math';
content: string;
formula: string;
};
export default function(text: string) {
const match = text.match(/^\$(.+?)\$/);
if (!match) return null;
const math = match[0];
return {
type: 'math',
content: math,
formula: match[1]
} as TextElementMath;
}