diff --git a/src/mfm/language.ts b/src/mfm/language.ts index ced8f84547..b9fe7bdef3 100644 --- a/src/mfm/language.ts +++ b/src/mfm/language.ts @@ -184,7 +184,13 @@ export const mfmLanguage = P.createLanguage({ }); }, emoji: () => { - const name = P.regexp(/:([a-z0-9_+-]+):/i, 1).map(x => createLeaf('emoji', { name: x })); + const name = P((input, i) => { + const text = input.substring(i); + const match = text.match(/^(\*|:)([a-zA-Z0-9_+-]+?)\1/); + if (!match) return P.makeFailure(i, 'not a emoji'); + if (input[i - 1] != null && input[i - 1].match(/[a-zA-Z0-9_+-]/i)) return P.makeFailure(i, 'not a emoji'); + return P.makeSuccess(i + match[0].length, match[2]); + }).map(x => createLeaf('emoji', { name: x })); const code = P.regexp(emojiRegex).map(x => createLeaf('emoji', { emoji: x })); return P.alt(name, code); },