[MFM] Fix emoji syntax parsing

This commit is contained in:
syuilo 2018-11-03 22:35:24 +09:00
parent 672947731c
commit 905bde1ba5
2 changed files with 10 additions and 3 deletions

View File

@ -9,7 +9,7 @@ export type TextElementEmoji = {
};
export default function(text: string) {
const match = text.match(/^:([a-zA-Z0-9+-_]+):/);
const match = text.match(/^:([a-zA-Z0-9+-_]+?):/);
if (!match) return null;
const emoji = match[0];
return {

View File

@ -180,10 +180,17 @@ describe('Text', () => {
});
it('emoji', () => {
const tokens = analyze(':cat:');
const tokens1 = analyze(':cat:');
assert.deepEqual([
{ type: 'emoji', content: ':cat:', emoji: 'cat'}
], tokens);
], tokens1);
const tokens2 = analyze(':cat::cat::cat:');
assert.deepEqual([
{ type: 'emoji', content: ':cat:', emoji: 'cat'},
{ type: 'emoji', content: ':cat:', emoji: 'cat'},
{ type: 'emoji', content: ':cat:', emoji: 'cat'}
], tokens2);
});
it('block code', () => {