Fix bug
This commit is contained in:
parent
556677be7a
commit
00f979f0e6
5 changed files with 34 additions and 16 deletions
19
src/misc/extract-mentions.ts
Normal file
19
src/misc/extract-mentions.ts
Normal file
|
@ -0,0 +1,19 @@
|
|||
import parse from '../mfm/parse';
|
||||
import { Node, IMentionNode } from '../mfm/parser';
|
||||
|
||||
export default function(tokens: ReturnType<typeof parse>): IMentionNode['props'][] {
|
||||
const mentions: IMentionNode['props'][] = [];
|
||||
|
||||
const extract = (tokens: Node[]) => {
|
||||
for (const x of tokens.filter(x => x.name === 'mention')) {
|
||||
mentions.push(x.props);
|
||||
}
|
||||
for (const x of tokens.filter(x => x.children)) {
|
||||
extract(x.children);
|
||||
}
|
||||
};
|
||||
|
||||
extract(tokens);
|
||||
|
||||
return mentions;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue