Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions src/internal/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
// tsdのテストでファイルを追加しているにも関わらず「@twemoji/parser/dist/lib/regex」の型定義ファイルがないとエラーが出るため、
// このエラーを無視する。
/* eslint @typescript-eslint/ban-ts-comment: 1 */
// @ts-ignore

Check warning on line 10 in src/internal/parser.ts

View workflow job for this annotation

GitHub Actions / lint

Use "@ts-expect-error" instead of "@ts-ignore", as "@ts-ignore" will do nothing if the following line is error-free
import twemojiRegex from '@twemoji/parser/dist/lib/regex';

type ArgPair = { k: string, v: string | true };
Expand Down Expand Up @@ -84,7 +84,7 @@
italicUnder: M.NodeType<'italic'>,
strikeTag: M.NodeType<'strike'> | string,
strikeWave: M.NodeType<'strike'> | string,
unicodeEmoji: M.NodeType<'unicodeEmoji'>,
unicodeEmoji: M.NodeType<'unicodeEmoji'> | string,
plainTag: M.NodeType<'plain'>,
fn: M.NodeType<'fn'> | string,
inlineCode: M.NodeType<'inlineCode'>,
Expand Down Expand Up @@ -458,7 +458,10 @@

unicodeEmoji: () => {
const emoji = RegExp(twemojiRegex.source);
return P.regexp(emoji).map(content => M.UNI_EMOJI(content));
return P.regexp(emoji).map(content => {
// 異体字セレクタ(U+FE0F)の場合は文字として返す
return content === '\uFE0F' ? content : M.UNI_EMOJI(content);
});
},

plainTag: () => {
Expand Down
6 changes: 6 additions & 0 deletions test/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,12 @@ describe('SimpleParser', () => {
const output = [TEXT('あ'), EMOJI_CODE('bar'), TEXT('い')];
assert.deepStrictEqual(mfm.parseSimple(input), output);
});

test('Ignore Variation Selector preceded by Unicode Emoji', () => {
const input = '\uFE0F';
const output = [TEXT('\uFE0F')];
assert.deepStrictEqual(mfm.parseSimple(input), output);
})
});

test('disallow other syntaxes', () => {
Expand Down
Loading