From 4b145da04655344c27eda93d7a8c4270b14df1c1 Mon Sep 17 00:00:00 2001 From: syuilo Date: Mon, 29 Oct 2018 19:09:24 +0900 Subject: [PATCH] Fix MFM parsing --- src/mfm/parse/elements/quote.ts | 3 ++- test/mfm.ts | 5 +++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/mfm/parse/elements/quote.ts b/src/mfm/parse/elements/quote.ts index 994ce98ca8..f846ec561b 100644 --- a/src/mfm/parse/elements/quote.ts +++ b/src/mfm/parse/elements/quote.ts @@ -17,7 +17,8 @@ export default function(text: string, index: number) { const quote = match[1] .split('\n') .map(line => line.replace(/^>+/g, '').trim()) - .join('\n'); + .join('\n') + .trim(); return { type: 'quote', diff --git a/test/mfm.ts b/test/mfm.ts index 370c638416..0ef2c91bcb 100644 --- a/test/mfm.ts +++ b/test/mfm.ts @@ -152,6 +152,11 @@ describe('Text', () => { assert.deepEqual([ { type: 'quote', content: '> foo\n> bar\n> baz', quote: 'foo\nbar\nbaz' } ], tokens4); + + const tokens5 = analyze('"\nfoo\nbar\nbaz\n"'); + assert.deepEqual([ + { type: 'quote', content: '"\nfoo\nbar\nbaz\n"', quote: 'foo\nbar\nbaz' } + ], tokens5); }); it('url', () => {