Merge pull request #44 from mbattista/fix-emojis

fix emojis
This commit is contained in:
Miroslav Šedivý 2021-04-05 01:11:36 +02:00 committed by GitHub
commit 89dd22727c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 23 deletions

View File

@ -55,7 +55,7 @@
"@vue/eslint-config-prettier": "^6.0.0", "@vue/eslint-config-prettier": "^6.0.0",
"@vue/eslint-config-typescript": "^7.0.0", "@vue/eslint-config-typescript": "^7.0.0",
"core-js": "^3.9.1", "core-js": "^3.9.1",
"emojilib": "^2.4.0", "emojilib": "^3.0.1",
"eslint": "^6.8.0", "eslint": "^6.8.0",
"eslint-plugin-prettier": "^3.1.4", "eslint-plugin-prettier": "^3.1.4",
"eslint-plugin-vue": "^7.8.0", "eslint-plugin-vue": "^7.8.0",

File diff suppressed because one or more lines are too long

View File

@ -2,7 +2,7 @@ import * as fs from 'fs'
import { custom } from './emoji_custom' import { custom } from './emoji_custom'
const datasource = require('emoji-datasource/emoji.json') as EmojiDatasource[] const datasource = require('emoji-datasource/emoji.json') as EmojiDatasource[]
const emojis = require('emojilib/emojis.json') as { [id: string]: Emoji } const emojis = require('emojilib')
interface EmojiDatasource { interface EmojiDatasource {
name: string name: string
@ -43,13 +43,6 @@ interface EmojiDatasource {
obsoleted_by: string obsoleted_by: string
} }
interface Emoji {
keywords: string[]
char: string
fitzpatrick_scale: boolean
category: string
}
const SHEET_COLUMNS = 58 const SHEET_COLUMNS = 58
const MULTIPLY = 100 / (SHEET_COLUMNS - 1) const MULTIPLY = 100 / (SHEET_COLUMNS - 1)
@ -70,16 +63,6 @@ for (const emoji of custom) {
for (const source of datasource) { for (const source of datasource) {
const unified = source.unified.split('-').map(v => v.toLowerCase()) const unified = source.unified.split('-').map(v => v.toLowerCase())
let emoji: Emoji | null = null
let emoji_id: string = ''
for (const id of Object.keys(emojis)) {
if (unified.includes(emojis[id].char.codePointAt(0)!.toString(16))) {
emoji_id = id
emoji = emojis[id]
break
}
}
if (!source.has_img_twitter) { if (!source.has_img_twitter) {
console.log(source.short_name, 'not avalible for set twitter') console.log(source.short_name, 'not avalible for set twitter')
continue continue
@ -87,10 +70,15 @@ for (const source of datasource) {
// keywords // keywords
let words: string[] = [] let words: string[] = []
if (!emoji) { for (const id of Object.keys(emojis)) {
if (unified.includes(id.codePointAt(0)!.toString(16))) {
words = [id, ...emojis[id]]
break
}
}
if (words.length == 0) {
console.log(source.short_name, 'no keywords') console.log(source.short_name, 'no keywords')
} else {
words = [emoji_id, ...emoji.keywords]
} }
for (const name of source.short_names) { for (const name of source.short_names) {