blob: 86ce8ab472313797891b5938ea25a04f057eeb0d (
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;
}
|