mirror of
https://activitypub.software/TransFem-org/sfm-js
synced 2024-11-21 21:55:09 +00:00
parent
363b091a67
commit
013f3af23e
2 changed files with 17 additions and 2 deletions
|
@ -626,12 +626,15 @@ export const language = P.createLanguage({
|
|||
},
|
||||
|
||||
emojiCode: r => {
|
||||
const side = P.notMatch(P.regexp(/[a-z0-9]/i));
|
||||
const mark = P.str(':');
|
||||
return P.seq([
|
||||
P.alt([P.lineBegin, side]),
|
||||
mark,
|
||||
P.regexp(/[a-z0-9_+-]+/i),
|
||||
mark,
|
||||
], 1).map(name => M.EMOJI_CODE(name as string));
|
||||
P.alt([P.lineEnd, side]),
|
||||
], 2).map(name => M.EMOJI_CODE(name as string));
|
||||
},
|
||||
|
||||
link: r => {
|
||||
|
|
|
@ -34,7 +34,19 @@ describe('SimpleParser', () => {
|
|||
|
||||
it('between texts', () => {
|
||||
const input = 'foo:bar:baz';
|
||||
const output = [TEXT('foo'), EMOJI_CODE('bar'), TEXT('baz')];
|
||||
const output = [TEXT('foo:bar:baz')];
|
||||
assert.deepStrictEqual(mfm.parseSimple(input), output);
|
||||
});
|
||||
|
||||
it('between texts 2', () => {
|
||||
const input = '12:34:56';
|
||||
const output = [TEXT('12:34:56')];
|
||||
assert.deepStrictEqual(mfm.parseSimple(input), output);
|
||||
});
|
||||
|
||||
it('between texts 3', () => {
|
||||
const input = 'あ:bar:い';
|
||||
const output = [TEXT('あ'), EMOJI_CODE('bar'), TEXT('い')];
|
||||
assert.deepStrictEqual(mfm.parseSimple(input), output);
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue