From d0926a3ba1e4666cad7ffb4aac4ff5fdc3a1476b Mon Sep 17 00:00:00 2001 From: syuilo Date: Sun, 5 Aug 2018 23:56:08 +0900 Subject: [PATCH] =?UTF-8?q?MFM=E3=81=AE((()))=E6=A7=8B=E6=96=87=E3=81=8C?= =?UTF-8?q?=E9=A1=94=E6=96=87=E5=AD=97=E3=81=A8=E7=AB=B6=E5=90=88=E3=81=99?= =?UTF-8?q?=E3=82=8B=E5=AF=BE=E7=AD=96=E3=81=A8=E3=81=97=E3=81=A6=E3=82=BF?= =?UTF-8?q?=E3=82=B0=E5=BD=A2=E5=BC=8F=E3=81=AE=E6=A7=8B=E6=96=87=E3=82=82?= =?UTF-8?q?=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/mfm/parse/elements/motion.ts | 2 +- test/mfm.ts | 10 ++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/mfm/parse/elements/motion.ts b/src/mfm/parse/elements/motion.ts index 555a98975..9e7370e07 100644 --- a/src/mfm/parse/elements/motion.ts +++ b/src/mfm/parse/elements/motion.ts @@ -9,7 +9,7 @@ export type TextElementMotion = { }; export default function(text: string) { - const match = text.match(/^\(\(\((.+?)\)\)\)/); + const match = text.match(/^\(\(\((.+?)\)\)\)/) || text.match(/^(.+?)<\/motion>/); if (!match) return null; const motion = match[0]; return { diff --git a/test/mfm.ts b/test/mfm.ts index 652a6e982..697d92e17 100644 --- a/test/mfm.ts +++ b/test/mfm.ts @@ -40,11 +40,17 @@ describe('Text', () => { }); it('motion', () => { - const tokens = analyze('(((Strawberry))) Pasta'); + const tokens1 = analyze('(((Strawberry))) Pasta'); assert.deepEqual([ { type: 'motion', content: '(((Strawberry)))', motion: 'Strawberry' }, { type: 'text', content: ' Pasta' } - ], tokens); + ], tokens1); + + const tokens2 = analyze('Strawberry Pasta'); + assert.deepEqual([ + { type: 'motion', content: 'Strawberry', motion: 'Strawberry' }, + { type: 'text', content: ' Pasta' } + ], tokens2); }); it('mention', () => {