1
0
forked from mirror/misskey

[MFM] Better hashtag detection

This commit is contained in:
syuilo 2018-10-31 22:38:05 +09:00
parent 1a51b98700
commit 04aff8866e
No known key found for this signature in database
GPG Key ID: BDC4C49D06AB9D69

View File

@ -9,9 +9,9 @@ export type TextElementHashtag = {
}; };
export default function(text: string, i: number) { export default function(text: string, i: number) {
if (!(/^\s#[^\s\.,!\?]+/.test(text) || (i == 0 && /^#[^\s\.,!\?]+/.test(text)))) return null; if (!(/^\s#[^\s\.,!\?#]+/.test(text) || (i == 0 && /^#[^\s\.,!\?#]+/.test(text)))) return null;
const isHead = text.startsWith('#'); const isHead = text.startsWith('#');
const hashtag = text.match(/^\s?#[^\s\.,!\?]+/)[0]; const hashtag = text.match(/^\s?#[^\s\.,!\?#]+/)[0];
const res: any[] = !isHead ? [{ const res: any[] = !isHead ? [{
type: 'text', type: 'text',
content: text[0] content: text[0]