From 63c659bc8fd8ddd6eda1462f29a61315955c112f Mon Sep 17 00:00:00 2001 From: syuilo Date: Sun, 16 Jun 2019 21:42:57 +0900 Subject: [PATCH] Fix MFM strike parsing --- src/mfm/language.ts | 2 +- test/mfm.ts | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/mfm/language.ts b/src/mfm/language.ts index 7da1af7cff..bfa22e8c3b 100644 --- a/src/mfm/language.ts +++ b/src/mfm/language.ts @@ -104,7 +104,7 @@ export const mfmLanguage = P.createLanguage({ return P.alt(xml, underscore).map(x => createTree('italic', r.inline.atLeast(1).tryParse(x), {})); }, - strike: r => P.regexp(/~~(.+?)~~/, 1).map(x => createTree('strike', r.inline.atLeast(1).tryParse(x), {})), + strike: r => P.regexp(/~~([^\n~]+?)~~/, 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); diff --git a/test/mfm.ts b/test/mfm.ts index cdd07788ba..c772a62dcb 100644 --- a/test/mfm.ts +++ b/test/mfm.ts @@ -1116,6 +1116,14 @@ describe('MFM', () => { ], {}), ]); }); + + // https://misskey.io/notes/7u1kv5dmia + it('ignore internal tilde', () => { + const tokens = parse('~~~~~'); + assert.deepStrictEqual(tokens, [ + text('~~~~~') + ]); + }); }); describe('italic', () => {