From 7fea20724b6a7fc1bd92c267af6b623a92958e61 Mon Sep 17 00:00:00 2001 From: Vincent Batts Date: Tue, 7 Feb 2017 14:30:57 -0500 Subject: [PATCH] main: make the Map use the first colon notation Signed-off-by: Vincent Batts --- emoji/map.go | 4 ++-- main.go | 8 +++++++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/emoji/map.go b/emoji/map.go index 50c7b29..4010eb0 100644 --- a/emoji/map.go +++ b/emoji/map.go @@ -25,10 +25,10 @@ type VersionedMap struct { } // Words are a set of options to represent an emoji. -// Possible options could be the ":colon_notion:" or a "U+26CF" style codepoint. +// Possible options could be the ":colon_notation:" or a "U+26CF" style codepoint. type Words []string -// IsColonNotation checks for whether a word is the :colon_notion: of emoji +// IsColonNotation checks for whether a word is the :colon_notation: of emoji func IsColonNotation(word string) bool { return strings.HasPrefix(word, ":") && strings.HasSuffix(word, ":") } diff --git a/main.go b/main.go index 544ad9a..2a3b068 100644 --- a/main.go +++ b/main.go @@ -174,7 +174,13 @@ func Sum(r io.Reader) ([]byte, error) { func emojiFromBytes(buf []byte) string { var ret string for _, b := range buf { - ret = ret + esum.Map(b)[0] + for _, e := range esum.Map(b) { + // use the first colon notation word and continue + if esum.IsColonNotation(e) { + ret = ret + e + break + } + } } return ret }