[MFM] Improve hashtag detection
This commit is contained in:
parent
24ef98eb01
commit
2c6bad2501
2 changed files with 39 additions and 10 deletions
29
test/mfm.ts
29
test/mfm.ts
|
@ -213,21 +213,44 @@ describe('Text', () => {
|
|||
});
|
||||
|
||||
it('with brackets', () => {
|
||||
const tokens = analyze('(#foo)');
|
||||
const tokens1 = analyze('(#foo)');
|
||||
assert.deepEqual([
|
||||
text('('),
|
||||
node('hashtag', { hashtag: 'foo' }),
|
||||
text(')'),
|
||||
], tokens1);
|
||||
|
||||
const tokens2 = analyze('「#foo」');
|
||||
assert.deepEqual([
|
||||
text('「'),
|
||||
node('hashtag', { hashtag: 'foo' }),
|
||||
text('」'),
|
||||
], tokens2);
|
||||
});
|
||||
|
||||
it('with mixed brackets', () => {
|
||||
const tokens = analyze('「#foo(bar)」');
|
||||
assert.deepEqual([
|
||||
text('「'),
|
||||
node('hashtag', { hashtag: 'foo(bar)' }),
|
||||
text('」'),
|
||||
], tokens);
|
||||
});
|
||||
|
||||
it('with brackets (space before)', () => {
|
||||
const tokens = analyze('(bar #foo)');
|
||||
const tokens1 = analyze('(bar #foo)');
|
||||
assert.deepEqual([
|
||||
text('(bar '),
|
||||
node('hashtag', { hashtag: 'foo' }),
|
||||
text(')'),
|
||||
], tokens);
|
||||
], tokens1);
|
||||
|
||||
const tokens2 = analyze('「bar #foo」');
|
||||
assert.deepEqual([
|
||||
text('「bar '),
|
||||
node('hashtag', { hashtag: 'foo' }),
|
||||
text('」'),
|
||||
], tokens2);
|
||||
});
|
||||
|
||||
it('disallow number only', () => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue