Browse Source

added notes

pull/34/head
David Haukeness 5 years ago
parent
commit
b0ea0c0b63
No known key found for this signature in database
GPG Key ID: A7F1091956853EF9
  1. 7
      emojiMap.go

7
emojiMap.go

@ -6,6 +6,8 @@ import ( @@ -6,6 +6,8 @@ import (
"strings"
)
// this is a global var set by flag that indicates whether emoji shortnames should be reprinted as unicode emojis
// some systems may support this
var UNICODE_EMOJI_SUPPORT bool = false
type emojiData struct {
@ -15,7 +17,9 @@ type emojiData struct { @@ -15,7 +17,9 @@ type emojiData struct {
Alias []string
}
// this converts shortname emojis to unicode emojis when they can be found in the data map
func emojiUnicodeConvert(s string) string {
// currently fails to find newlines and replace them needs fixed
pStr := strings.Fields(s)
reeMatch := regexp.MustCompile(`:\w+:`)
for i, word := range pStr {
@ -32,6 +36,8 @@ func emojiUnicodeConvert(s string) string { @@ -32,6 +36,8 @@ func emojiUnicodeConvert(s string) string {
return strings.Join(pStr, " ")
}
// this resolves emoji aliases back to the root emoji that actually renders to a picture
// for example `:cheeseburger:` => `:hamburger:`
func resolveRootEmojis(s string) string {
pStr := strings.Fields(s)
reMatch := regexp.MustCompile(`:\w+:`)
@ -46,6 +52,7 @@ func resolveRootEmojis(s string) string { @@ -46,6 +52,7 @@ func resolveRootEmojis(s string) string {
return strings.Join(pStr, " ")
}
// this is the actual internal function that parses the unicode data to a unicode string representing the emoji
func renderUnicodeEmoji(data emojiData) (string, error) {
emj, err := strconv.ParseInt(data.Unicode, 16, 32)
if err != nil {

Loading…
Cancel
Save