diff --git a/src/mfm/parser.ts b/src/mfm/parser.ts index 047124e582..5a20c7ef2b 100644 --- a/src/mfm/parser.ts +++ b/src/mfm/parser.ts @@ -112,6 +112,7 @@ const mfm = P.createLanguage({ const text = input.substr(i); const match = text.match(/^#([^\s\.,!\?#]+)/i); 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 "#"'); return P.makeSuccess(i + match[0].length, makeNode('hashtag', { hashtag: match[1] })); }), diff --git a/test/mfm.ts b/test/mfm.ts index a40f769f80..8ca09c7417 100644 --- a/test/mfm.ts +++ b/test/mfm.ts @@ -204,6 +204,13 @@ describe('Text', () => { text('!'), ], tokens); }); + + it('disallow number only', () => { + const tokens = analyze('#123'); + assert.deepEqual([ + text('#123'), + ], tokens); + }); }); describe('quote', () => {