summaryrefslogtreecommitdiff
path: root/src/mfm/parse/elements/motion.ts
blob: c6500e7be0acbf61aaac392804e1e44763e9465c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
/**
 * Motion
 */

export type TextElementMotion = {
	type: 'motion';
	content: string;
	motion: string;
};

export default function(text: string) {
	const match = text.match(/^\(\(\((.+?)\)\)\)/) || text.match(/^<motion>(.+?)<\/motion>/);
	if (!match) return null;
	const motion = match[0];
	return {
		type: 'motion',
		content: motion,
		motion: match[1]
	} as TextElementMotion;
}