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

export type TextElementTitle = {
	type: "title"
	content: string
	title: string
};

export default function(text: string) {
	const match = text.match(/^【(.+?)】\n/);
	if (!match) return null;
	const title = match[0];
	return {
		type: 'title',
		content: title,
		title: title.substr(1, title.length - 3)
	} as TextElementTitle;
}