mirror of
https://github.com/kokonect-link/cherrypick
synced 2024-12-02 08:48:32 +09:00
[MFM] Better hashtag detection
This commit is contained in:
parent
1a51b98700
commit
04aff8866e
@ -9,9 +9,9 @@ export type TextElementHashtag = {
|
||||
};
|
||||
|
||||
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 hashtag = text.match(/^\s?#[^\s\.,!\?]+/)[0];
|
||||
const hashtag = text.match(/^\s?#[^\s\.,!\?#]+/)[0];
|
||||
const res: any[] = !isHead ? [{
|
||||
type: 'text',
|
||||
content: text[0]
|
||||
|
Loading…
Reference in New Issue
Block a user