Fixed 267U.pre2

This commit is contained in:
2026-07-26 18:25:37 +09:00
parent 50bfaeafdf
commit 317d00a284
1286 changed files with 80222 additions and 1 deletions
@@ -0,0 +1,24 @@
import * as mfm from "mfm-js";
import { unique } from "../prelude/array.js";
const wrappedEmojiRegex = /([:;])([^:;\s]{1,100})\1/g;
const glyphEmojiRegex = /;([^:;\s]{1,100});/g;
export function extractCustomEmojisFromMfm(nodes) {
const emojiNodes = mfm.extract(nodes, (node)=>{
return node.type === "emojiCode" && node.props.name.length <= 100;
});
const glyphNames = mfm.extract(nodes, (node)=>node.type === "text").flatMap((node)=>Array.from(node.props.text.matchAll(glyphEmojiRegex), (match)=>match[1]));
return unique([
...emojiNodes.map((x)=>x.props.name),
...glyphNames
]);
}
export function extractCustomEmojiNamesFromText(texts) {
const emojis = [];
for (const text of texts){
if (!text) continue;
for (const match of text.matchAll(wrappedEmojiRegex)){
emojis.push(match[2]);
}
}
return unique(emojis);
}