From 4cdf5f82a1ba01d16403d62c5ca89ce7199593d3 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 994ce98ca..f846ec561 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 370c63841..0ef2c91bc 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', () => {