2018-02-27 12:32:01 +09:00
|
|
|
/**
|
|
|
|
|
* Quoted text
|
|
|
|
|
*/
|
|
|
|
|
|
2018-06-17 19:55:39 +09:00
|
|
|
export type TextElementQuote = {
|
2018-06-18 14:28:43 +09:00
|
|
|
type: 'quote'
|
2018-06-17 19:55:39 +09:00
|
|
|
content: string
|
|
|
|
|
quote: string
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export default function(text: string) {
|
2018-09-20 06:27:41 +09:00
|
|
|
const match = text.match(/^"([\s\S]+?)\n"/) || text.match(/^>([\s\S]+?)\n\n/) || text.match(/^\n>([\s\S]+?)\n\n/) || text.match(/^>([\s\S]+?)$/);
|
2018-02-27 12:32:01 +09:00
|
|
|
if (!match) return null;
|
|
|
|
|
const quote = match[0];
|
|
|
|
|
return {
|
|
|
|
|
type: 'quote',
|
|
|
|
|
content: quote,
|
2018-08-15 20:27:49 +09:00
|
|
|
quote: match[1].trim(),
|
2018-06-17 19:55:39 +09:00
|
|
|
} as TextElementQuote;
|
|
|
|
|
}
|