sharkey/src/misc/extract-custom-emojis-from-mfm.ts
marihachi 3a6331693a
refactor mfm extract (#7434)
* refactor extractCustomEmojisFromMfm()

* refactor extract-hashtags

* refactor extract-mentions

* refactor extract-hashtags

* refactor extract-url-from-mfm

* refactor extract-mentions
2021-04-10 17:50:18 +09:00

15 lines
353 B
TypeScript

import * as mfm from 'mfm-js';
import { unique } from '@/prelude/array';
export function extractCustomEmojisFromMfm(nodes: mfm.MfmNode[]): string[] {
const emojis = [] as string[];
mfm.inspect(nodes, (node) => {
if (node.type === 'emojiCode' && node.props.name.length <= 100) {
emojis.push(node.props.name);
}
});
return unique(emojis);
}