2023-11-21 19:19:47 +08:00
|
|
|
// Generates emoji.json from emoji-data.txt
|
|
|
|
const emojiRe = /#\s([^\s]+)\s+E[^\s]+\s+(.+)$/;
|
|
|
|
|
2024-07-30 21:17:34 +08:00
|
|
|
const text = Deno.readTextFileSync("emoji-data.txt");
|
2023-11-21 19:19:47 +08:00
|
|
|
const lines = text.split("\n").filter((line) => !line.startsWith("#"));
|
|
|
|
|
|
|
|
const emojis: string[] = [];
|
|
|
|
for (const line of lines) {
|
2024-07-30 21:17:34 +08:00
|
|
|
const match = emojiRe.exec(line);
|
2023-11-21 19:19:47 +08:00
|
|
|
if (match) {
|
|
|
|
const emoji = match[1];
|
|
|
|
const name = match[2].toLowerCase().replaceAll(/\W+/g, "_");
|
|
|
|
emojis.push(`${name} ${emoji}`);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Deno.writeFileSync(
|
|
|
|
"emoji.json",
|
|
|
|
new TextEncoder().encode(JSON.stringify(emojis.join("|"))),
|
|
|
|
);
|