[MFM] Fix emoji syntax parsing
This commit is contained in:
parent
f5d53d784d
commit
600aea4dbb
@ -9,7 +9,7 @@ export type TextElementEmoji = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export default function(text: string) {
|
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;
|
if (!match) return null;
|
||||||
const emoji = match[0];
|
const emoji = match[0];
|
||||||
return {
|
return {
|
||||||
|
11
test/mfm.ts
11
test/mfm.ts
@ -180,10 +180,17 @@ describe('Text', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('emoji', () => {
|
it('emoji', () => {
|
||||||
const tokens = analyze(':cat:');
|
const tokens1 = analyze(':cat:');
|
||||||
assert.deepEqual([
|
assert.deepEqual([
|
||||||
{ type: 'emoji', content: ':cat:', emoji: 'cat'}
|
{ 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', () => {
|
it('block code', () => {
|
||||||
|
Loading…
Reference in New Issue
Block a user