Better hashtag parsing
This commit is contained in:
parent
71bada97df
commit
f5a937c523
2 changed files with 13 additions and 4 deletions
|
@ -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…
Add table
Add a link
Reference in a new issue