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

export type TextElementEmoji = {
	type: 'emoji'
	content: string
	emoji: string
};

export default function(text: string) {
	const match = text.match(/^:([a-zA-Z0-9+-_]+):/);
	if (!match) return null;
	const emoji = match[0];
	return {
		type: 'emoji',
		content: emoji,
		emoji: match[1]
	} as TextElementEmoji;
}