Skip to content
Open
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
9 changes: 0 additions & 9 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,6 @@
"typescript": "5.8.3",
"vitest": "^3.2.4"
},
"dependencies": {
"@twemoji/parser": "16.0.0"
},
"files": [
"built",
"CHANGELOG.md"
Expand Down
4 changes: 0 additions & 4 deletions src/@types/twemoji.d.ts

This file was deleted.

15 changes: 6 additions & 9 deletions src/internal/parser.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,3 @@
// NOTE:
// tsdのテストでファイルを追加しているにも関わらず「@twemoji/parser/dist/lib/regex」の型定義ファイルがないとエラーが出るため、
// このエラーを無視する。
/* eslint @typescript-eslint/ban-ts-comment: 1 */
// @ts-ignore
import twemojiRegex from '@twemoji/parser/dist/lib/regex';

import * as M from '..';
import * as P from './core';
import { mergeText } from './util';
Expand All @@ -17,6 +10,11 @@
const alphaAndNum = P.regexp(/[a-z0-9]/i);
const newLine = P.alt([P.crlf, P.cr, P.lf]);

// taken from https://github.com/slevithan/emoji-regex-xs
const r = String.raw;
const base = r`\p{Emoji}(?:\p{EMod}|[\u{E0020}-\u{E007E}]+\u{E007F}|\uFE0F?\u20E3?)`;
const emojiRegex = new RegExp(r`\p{RI}{2}|(?![#*\d](?!\uFE0F?\u20E3))${base}(?:\u200D${base})*`, 'gu');

function seqOrText<Parsers extends P.Parser<unknown>[]>(...parsers: Parsers): P.Parser<SeqParseResult<Parsers> | string> {
return new P.Parser<SeqParseResult<Parsers> | string>((input, index, state) => {
// TODO: typesafe implementation
Expand Down Expand Up @@ -54,7 +52,7 @@
// nesting limited? -> No: specified parser, Yes: fallback parser (default = P.char)
const inner = P.alt([
P.seq(nestable, parser).select(1),
(fallback != null) ? fallback : P.char,

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

View workflow job for this annotation

GitHub Actions / lint

Prefer using nullish coalescing operator (`??`) instead of a ternary expression, as it is simpler to read

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

View workflow job for this annotation

GitHub Actions / lint

Prefer using nullish coalescing operator (`??`) instead of a ternary expression, as it is simpler to read
]);
return new P.Parser<T | string>((input, index, state) => {
state.depth++;
Expand Down Expand Up @@ -457,8 +455,7 @@
},

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