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', () => {