summaryrefslogtreecommitdiff
path: root/src/mfm/parse/elements/math.ts
blob: b10efe515f2234933c2c6c4078283ff56a8a99b4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
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;
}