From d5dfdd3882d9718fd9b7c544d355c49ceb465ec2 Mon Sep 17 00:00:00 2001 From: ikasoba <57828948+ikasoba@users.noreply.github.com> Date: Tue, 26 Dec 2023 20:09:23 +0900 Subject: [PATCH] =?UTF-8?q?U+FE0F=E3=81=AA=E3=81=A9=E3=82=92=E7=A9=BA?= =?UTF-8?q?=E6=96=87=E5=AD=97=E3=81=A8=E3=81=97=E3=81=A6=E8=BF=94=E3=81=99?= =?UTF-8?q?=E3=82=88=E3=81=86=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/internal/parser.ts | 5 ++++- test/parser.ts | 6 ++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/internal/parser.ts b/src/internal/parser.ts index 20e0072..85e6589 100644 --- a/src/internal/parser.ts +++ b/src/internal/parser.ts @@ -420,7 +420,10 @@ export const language = P.createLanguage({ unicodeEmoji: r => { const emoji = RegExp(twemojiRegex.source); - return P.regexp(emoji).map(content => M.UNI_EMOJI(content)); + return P.regexp(emoji).map(content => { + // 異体字セレクタのみの場合は空文字として返す + return /^[\uFE00-\uFE0F]+$/u.test(content) ? M.TEXT('') : M.UNI_EMOJI(content); + }); }, plainTag: r => { diff --git a/test/parser.ts b/test/parser.ts index 50ae700..b51fa42 100644 --- a/test/parser.ts +++ b/test/parser.ts @@ -49,6 +49,12 @@ describe('SimpleParser', () => { const output = [TEXT('あ'), EMOJI_CODE('bar'), TEXT('い')]; assert.deepStrictEqual(mfm.parseSimple(input), output); }); + + test('U+FE0F', () => { + const input = '\uFE0F'; + const output = [TEXT('')]; + assert.deepStrictEqual(mfm.parseSimple(input), output); + }) }); test('disallow other syntaxes', () => {