From c2c87574c6a7080c60871c61549194a8a81ad977 Mon Sep 17 00:00:00 2001 From: ikasoba <57828948+ikasoba@users.noreply.github.com> Date: Tue, 26 Dec 2023 20:10:07 +0900 Subject: [PATCH 1/4] =?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', () => { From da6234bcf96cb6d18564f341948b26e011832e05 Mon Sep 17 00:00:00 2001 From: ikasoba <57828948+ikasoba@users.noreply.github.com> Date: Sat, 15 Jun 2024 23:08:22 +0900 Subject: [PATCH 2/4] Update test/parser.ts Co-authored-by: Kisaragi <48310258+KisaragiEffective@users.noreply.github.com> --- test/parser.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/parser.ts b/test/parser.ts index b51fa42..88cfcc2 100644 --- a/test/parser.ts +++ b/test/parser.ts @@ -50,7 +50,7 @@ describe('SimpleParser', () => { assert.deepStrictEqual(mfm.parseSimple(input), output); }); - test('U+FE0F', () => { + test('Ignore Variation Selector preceded by Unicode Emoji', () => { const input = '\uFE0F'; const output = [TEXT('')]; assert.deepStrictEqual(mfm.parseSimple(input), output); From 1da3013a230cdcbd96b1efe98e6a1ae88d650457 Mon Sep 17 00:00:00 2001 From: ikasoba <57828948+ikasoba@users.noreply.github.com> Date: Sat, 15 Jun 2024 23:36:36 +0900 Subject: [PATCH 3/4] =?UTF-8?q?U+FE0F=E3=81=AE=E3=81=BF=E3=81=A7=E3=81=82?= =?UTF-8?q?=E3=82=8C=E3=81=B0=E6=96=87=E5=AD=97=E3=81=A8=E3=81=97=E3=81=A6?= =?UTF-8?q?=E8=BF=94=E3=81=99=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 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/internal/parser.ts b/src/internal/parser.ts index 85e6589..2546cf8 100644 --- a/src/internal/parser.ts +++ b/src/internal/parser.ts @@ -421,8 +421,8 @@ export const language = P.createLanguage({ unicodeEmoji: r => { const emoji = RegExp(twemojiRegex.source); return P.regexp(emoji).map(content => { - // 異体字セレクタのみの場合は空文字として返す - return /^[\uFE00-\uFE0F]+$/u.test(content) ? M.TEXT('') : M.UNI_EMOJI(content); + // 異体字セレクタ(U+FE0F)の場合は文字として返す + return content == "\uFE0F" ? M.TEXT(content) : M.UNI_EMOJI(content); }); }, From bd997ccb9a387306139d98d30daaa8f7fb8de1e6 Mon Sep 17 00:00:00 2001 From: ikasoba <57828948+ikasoba@users.noreply.github.com> Date: Sat, 15 Jun 2024 23:43:12 +0900 Subject: [PATCH 4/4] =?UTF-8?q?lint=E3=82=A8=E3=83=A9=E3=83=BC=E4=BF=AE?= =?UTF-8?q?=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/internal/parser.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/internal/parser.ts b/src/internal/parser.ts index 2546cf8..d011f31 100644 --- a/src/internal/parser.ts +++ b/src/internal/parser.ts @@ -422,7 +422,7 @@ export const language = P.createLanguage({ const emoji = RegExp(twemojiRegex.source); return P.regexp(emoji).map(content => { // 異体字セレクタ(U+FE0F)の場合は文字として返す - return content == "\uFE0F" ? M.TEXT(content) : M.UNI_EMOJI(content); + return content === '\uFE0F' ? M.TEXT(content) : M.UNI_EMOJI(content); }); },