summaryrefslogtreecommitdiff
path: root/src/mfm/parse/elements/motion.ts
blob: 9e7370e071c9a0621788ebcf20ad264e193f14e7 (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;
}