From 54224826961e07b16679fdc083b6af2a30936241 Mon Sep 17 00:00:00 2001 From: syuilo Date: Thu, 20 Sep 2018 06:27:41 +0900 Subject: [PATCH] Resolve #1153 --- src/mfm/parse/elements/quote.ts | 2 +- test/mfm.ts | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/mfm/parse/elements/quote.ts b/src/mfm/parse/elements/quote.ts index ea99240d5f..aa932cbf8d 100644 --- a/src/mfm/parse/elements/quote.ts +++ b/src/mfm/parse/elements/quote.ts @@ -9,7 +9,7 @@ export type TextElementQuote = { }; export default function(text: string) { - const match = text.match(/^"([\s\S]+?)\n"/); + const match = text.match(/^"([\s\S]+?)\n"/) || text.match(/^>([\s\S]+?)\n\n/) || text.match(/^\n>([\s\S]+?)\n\n/) || text.match(/^>([\s\S]+?)$/); if (!match) return null; const quote = match[0]; return { diff --git a/test/mfm.ts b/test/mfm.ts index a015092f0c..25a7c290e4 100644 --- a/test/mfm.ts +++ b/test/mfm.ts @@ -87,6 +87,20 @@ describe('Text', () => { ], tokens2); }); + it('quote', () => { + const tokens1 = analyze('> foo\nbar\baz'); + assert.deepEqual([ + { type: 'quote', content: '> foo\nbar\baz', quote: 'foo\nbar\baz' } + ], tokens1); + + const tokens2 = analyze('before\n> foo\nbar\baz\n\nafter'); + assert.deepEqual([ + { type: 'text', content: 'before' }, + { type: 'quote', content: '\n> foo\nbar\baz\n\n', quote: 'foo\nbar\baz' }, + { type: 'text', content: 'after' } + ], tokens2); + }); + it('url', () => { const tokens = analyze('https://himasaku.net'); assert.deepEqual([{