Better hashtag parsing

This commit is contained in:
syuilo 2018-09-17 22:51:10 +09:00
parent 71bada97df
commit f5a937c523
No known key found for this signature in database
GPG key ID: BDC4C49D06AB9D69
2 changed files with 13 additions and 4 deletions

View file

@ -71,11 +71,20 @@ describe('Text', () => {
});
it('hashtag', () => {
const tokens = analyze('Strawberry Pasta #alice');
const tokens1 = analyze('Strawberry Pasta #alice');
assert.deepEqual([
{ type: 'text', content: 'Strawberry Pasta ' },
{ type: 'hashtag', content: '#alice', hashtag: 'alice' }
], tokens);
], tokens1);
const tokens2 = analyze('Foo #bar, baz #piyo.');
assert.deepEqual([
{ type: 'text', content: 'Foo ' },
{ type: 'hashtag', content: '#bar', hashtag: 'bar' },
{ type: 'text', content: ', baz ' },
{ type: 'hashtag', content: '#piyo', hashtag: 'piyo' },
{ type: 'text', content: '.' }
], tokens2);
});
it('url', () => {