now gets current emojis from unicode.org
This commit is contained in:
parent
e36842dcad
commit
f825d0ca59
3 changed files with 28 additions and 4 deletions
File diff suppressed because one or more lines are too long
|
@ -4,16 +4,24 @@ type
|
|||
Emoji* = object
|
||||
emoji*: string
|
||||
name*: string
|
||||
group*: string
|
||||
subgroup*: string
|
||||
|
||||
proc `$`(e: Emoji): string =
|
||||
return e.emoji & " : " & e.name
|
||||
return e.emoji & " : " & e.name & " : " & e.group & " : " & e.subgroup
|
||||
|
||||
const ignore_groups = ["Flags", "Symbols"]
|
||||
const include_groups_override = ["geometric", "other-symbol"]
|
||||
|
||||
proc getEmojis(): seq[string] =
|
||||
let file_emojis = staticRead("../../emojis.json")
|
||||
let emojis = file_emojis.fromJson(seq[Emoji])
|
||||
var list: seq[string] = @[]
|
||||
for emoji in emojis:
|
||||
list.add($emoji)
|
||||
for e in emojis:
|
||||
if e.group notin ignore_groups and e.subgroup in ignore_groups:
|
||||
list.add($e)
|
||||
if e.subgroup in include_groups_override:
|
||||
list.add($e)
|
||||
return list
|
||||
|
||||
const emoji_list = getEmojis()
|
||||
|
|
|
@ -6,9 +6,23 @@ import emurrjilist
|
|||
|
||||
var emojis: seq[Emoji] = @[]
|
||||
let e_re = re"E[0-9\.]+"
|
||||
const group_line = "# group: "
|
||||
const subgroup_line = "# subgroup: "
|
||||
|
||||
proc parse(body: string) =
|
||||
var current_group = ""
|
||||
var current_subgroup = ""
|
||||
for line in body.split("\n"):
|
||||
if line.startsWith(group_line):
|
||||
let g = line.replace(group_line, "")
|
||||
if current_group != g:
|
||||
current_group = g
|
||||
continue
|
||||
if line.startsWith(subgroup_line):
|
||||
let sub_g = line.replace(subgroup_line, "")
|
||||
if current_subgroup != sub_g:
|
||||
current_subgroup = sub_g
|
||||
continue
|
||||
if line == "" or (line.len > 0 and line[0] == '#'):
|
||||
continue
|
||||
try:
|
||||
|
@ -17,6 +31,8 @@ proc parse(body: string) =
|
|||
var emoji = Emoji()
|
||||
emoji.emoji = emo[0].strip(chars={' '})
|
||||
emoji.name = emo[1].strip()
|
||||
emoji.group = current_group
|
||||
emoji.subgroup = current_subgroup
|
||||
emojis.add(emoji)
|
||||
except:
|
||||
echo getCurrentExceptionMsg()
|
||||
|
|
Loading…
Reference in a new issue