rudeshark.net/src/misc/extract-mentions.ts
Aya Morisawa e9f8897fe2
Refactor MFM
Co-authored-by: syuilo syuilotan@yahoo.co.jp
2018-12-20 19:42:10 +09:00

11 lines
382 B
TypeScript

// test is located in test/extract-mentions
import { MentionNode, MfmForest } from '../mfm/parser';
import { preorderF } from '../prelude/tree';
export default function(mfmForest: MfmForest): MentionNode['props'][] {
// TODO: 重複を削除
const mentionNodes = preorderF(mfmForest).filter(x => x.type === 'mention') as MentionNode[];
return mentionNodes.map(x => x.props);
}