1
0
Fork 0
mirror of https://github.com/emojisum/emojisum.git synced 2025-01-24 03:40:07 +00:00

main: make the Map use the first colon notation

Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
This commit is contained in:
Vincent Batts 2017-02-07 14:30:57 -05:00
parent a9e159d830
commit 7fea20724b
Signed by: vbatts
GPG key ID: 10937E57733F1362
2 changed files with 9 additions and 3 deletions

View file

@ -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, ":")
}

View file

@ -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
}