[MFM] Better hashtag parsing

This commit is contained in:
syuilo 2018-11-25 04:44:42 +09:00
parent 02b07c1b5b
commit 3b10e93efe
No known key found for this signature in database
GPG key ID: BDC4C49D06AB9D69
2 changed files with 46 additions and 3 deletions

View file

@ -212,12 +212,37 @@ describe('Text', () => {
], tokens);
});
it('with brackets', () => {
const tokens = analyze('(#foo)');
assert.deepEqual([
text('('),
node('hashtag', { hashtag: 'foo' }),
text(')'),
], tokens);
});
it('with brackets (space before)', () => {
const tokens = analyze('(bar #foo)');
assert.deepEqual([
text('(bar '),
node('hashtag', { hashtag: 'foo' }),
text(')'),
], tokens);
});
it('disallow number only', () => {
const tokens = analyze('#123');
assert.deepEqual([
text('#123'),
], tokens);
});
it('disallow number only (with brackets)', () => {
const tokens = analyze('(#123)');
assert.deepEqual([
text('(#123)'),
], tokens);
});
});
describe('quote', () => {