mirror of
https://github.com/misskey-dev/misskey.git
synced 2024-12-25 00:49:17 +09:00
parent
73df6e0347
commit
1d1024c57a
@ -112,6 +112,7 @@ const mfm = P.createLanguage({
|
|||||||
const text = input.substr(i);
|
const text = input.substr(i);
|
||||||
const match = text.match(/^#([^\s\.,!\?#]+)/i);
|
const match = text.match(/^#([^\s\.,!\?#]+)/i);
|
||||||
if (!match) return P.makeFailure(i, 'not a hashtag');
|
if (!match) return P.makeFailure(i, 'not a hashtag');
|
||||||
|
if (match[1].match(/[0-9]+/)) return P.makeFailure(i, 'not a hashtag');
|
||||||
if (input[i - 1] != '\n' && input[i - 1] != ' ' && input[i - 1] != null) return P.makeFailure(i, 'require space before "#"');
|
if (input[i - 1] != '\n' && input[i - 1] != ' ' && input[i - 1] != null) return P.makeFailure(i, 'require space before "#"');
|
||||||
return P.makeSuccess(i + match[0].length, makeNode('hashtag', { hashtag: match[1] }));
|
return P.makeSuccess(i + match[0].length, makeNode('hashtag', { hashtag: match[1] }));
|
||||||
}),
|
}),
|
||||||
|
@ -204,6 +204,13 @@ describe('Text', () => {
|
|||||||
text('!'),
|
text('!'),
|
||||||
], tokens);
|
], tokens);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('disallow number only', () => {
|
||||||
|
const tokens = analyze('#123');
|
||||||
|
assert.deepEqual([
|
||||||
|
text('#123'),
|
||||||
|
], tokens);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('quote', () => {
|
describe('quote', () => {
|
||||||
|
Loading…
Reference in New Issue
Block a user