From a5f817d8962ff16b68109f0b55267fa021c6d3e8 Mon Sep 17 00:00:00 2001 From: syuilo Date: Fri, 21 Sep 2018 08:33:24 +0900 Subject: Fix #2744 --- src/mfm/parse/elements/quote.ts | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'src/mfm/parse/elements') diff --git a/src/mfm/parse/elements/quote.ts b/src/mfm/parse/elements/quote.ts index aa932cbf8d..994ce98ca8 100644 --- a/src/mfm/parse/elements/quote.ts +++ b/src/mfm/parse/elements/quote.ts @@ -8,13 +8,20 @@ export type TextElementQuote = { quote: string }; -export default function(text: string) { - const match = text.match(/^"([\s\S]+?)\n"/) || text.match(/^>([\s\S]+?)\n\n/) || text.match(/^\n>([\s\S]+?)\n\n/) || text.match(/^>([\s\S]+?)$/); +export default function(text: string, index: number) { + const match = text.match(/^"([\s\S]+?)\n"/) || text.match(/^\n>([\s\S]+?)(\n\n|$)/) || + (index == 0 ? text.match(/^>([\s\S]+?)(\n\n|$)/) : null); + if (!match) return null; - const quote = match[0]; + + const quote = match[1] + .split('\n') + .map(line => line.replace(/^>+/g, '').trim()) + .join('\n'); + return { type: 'quote', - content: quote, - quote: match[1].trim(), + content: match[0], + quote: quote, } as TextElementQuote; } -- cgit v1.2.3-freya