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

export type TextElementSearch = {
	type: 'search';
	content: string;
	query: string;
};

export default function(text: string) {
	const match = text.match(/^(.+?)( | )(検索|\[検索\]|Search|\[Search\])(\n|$)/i);
	if (!match) return null;
	return {
		type: 'search',
		content: match[0],
		query: match[1]
	};
}