yumechi-no-kuni/src/mfm/parse/elements/search.ts

20 lines
332 B
TypeScript
Raw Normal View History

2018-04-21 04:59:16 -05:00
/**
* Search
*/
2018-06-17 05:55:39 -05:00
export type TextElementSearch = {
2018-06-18 00:28:43 -05:00
type: 'search'
2018-06-17 05:55:39 -05:00
content: string
query: string
};
export default function(text: string) {
2018-08-15 06:27:36 -05:00
const match = text.match(/^(.+?)( | )(検索|\[検索\]|Search|\[Search\])(\n|$)/i);
2018-04-21 04:59:16 -05:00
if (!match) return null;
return {
type: 'search',
content: match[0],
query: match[1]
};
2018-06-17 05:55:39 -05:00
}