diff --git a/src/mfm/language.ts b/src/mfm/language.ts index 8f35d443dc..75451f3bd4 100644 --- a/src/mfm/language.ts +++ b/src/mfm/language.ts @@ -108,20 +108,20 @@ export const mfmLanguage = P.createLanguage({ strike: r => P.regexp(/~~(.+?)~~/, 1).map(x => createTree('strike', r.inline.atLeast(1).tryParse(x), {})), motion: r => { const paren = P.regexp(/\(\(\(([\s\S]+?)\)\)\)/, 1); - const xml = P.regexp(/(.+?)<\/motion>/, 1); + const xml = P.regexp(/(.+)<\/motion>/, 1); return P.alt(paren, xml).map(x => createTree('motion', r.inline.atLeast(1).tryParse(x), {})); }, spin: r => { return P((input, i) => { const text = input.substr(i); - const match = text.match(/^(.+?)<\/spin>/i); + const match = text.match(/^(.+)<\/spin>/i); if (!match) return P.makeFailure(i, 'not a spin'); return P.makeSuccess(i + match[0].length, { content: match[2], attr: match[1] ? match[1].trim() : null }); }).map(x => createTree('spin', r.inline.atLeast(1).tryParse(x.content), { attr: x.attr })); }, - jump: r => P.regexp(/(.+?)<\/jump>/, 1).map(x => createTree('jump', r.inline.atLeast(1).tryParse(x), {})), + jump: r => P.regexp(/(.+)<\/jump>/, 1).map(x => createTree('jump', r.inline.atLeast(1).tryParse(x), {})), flip: r => P.regexp(/(.+?)<\/flip>/, 1).map(x => createTree('flip', r.inline.atLeast(1).tryParse(x), {})), center: r => r.startOfLine.then(P.regexp(/
([\s\S]+?)<\/center>/, 1).map(x => createTree('center', r.inline.atLeast(1).tryParse(x), {}))), inlineCode: () => P.regexp(/`([^ยด\n]+?)`/, 1).map(x => createLeaf('inlineCode', { code: x })), diff --git a/test/mfm.ts b/test/mfm.ts index 7e7d2bf56d..0de2e6b2c1 100644 --- a/test/mfm.ts +++ b/test/mfm.ts @@ -276,6 +276,21 @@ describe('MFM', () => { }), ]); }); + + it('nested', () => { + const tokens = parse(':foo:'); + assert.deepStrictEqual(tokens, [ + tree('spin', [ + tree('spin', [ + leaf('emoji', { name: 'foo' }) + ], { + attr: null + }), + ], { + attr: null + }), + ]); + }); }); it('jump', () => {