Support math rendering on MFM (#3260)
This commit is contained in:
20
src/mfm/parse/elements/math.ts
Normal file
20
src/mfm/parse/elements/math.ts
Normal 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;
|
||||
}
|
Reference in New Issue
Block a user