From b0ea0c0b63a87597604154306287b443ead1910a Mon Sep 17 00:00:00 2001 From: David Haukeness Date: Sun, 20 Oct 2019 15:53:40 -0600 Subject: [PATCH] added notes --- emojiMap.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/emojiMap.go b/emojiMap.go index fb706d6..a9a6bd4 100644 --- a/emojiMap.go +++ b/emojiMap.go @@ -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 { 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 { 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 { 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 {