[MFM] Fix hashtag detection

This commit is contained in:
syuilo
2018-11-24 17:18:11 +09:00
parent a479ad357c
commit dbbc416095
2 changed files with 8 additions and 1 deletions

View File

@ -112,7 +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 (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] }));
}),