Don't add any space around Emojis
authorBjΓΈrn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Mon, 9 May 2016 20:59:49 +0000 (22:59 +0200)
committerBjΓΈrn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Mon, 9 May 2016 20:59:49 +0000 (22:59 +0200)
helpers/emoji.go
helpers/emoji_test.go

index ad67378785fe04088187d839ade839ff22f013db..3b0b1605f169eead6e2239f2a5a0df3a75c06b8d 100644 (file)
@@ -15,8 +15,9 @@ package helpers
 
 import (
        "bytes"
-       "github.com/kyokomi/emoji"
        "sync"
+
+       "github.com/kyokomi/emoji"
 )
 
 var (
@@ -85,7 +86,7 @@ func initEmoji() {
        emojiMap := emoji.CodeMap()
 
        for k, v := range emojiMap {
-               emojis[k] = []byte(v + emoji.ReplacePadding)
+               emojis[k] = []byte(v)
 
                if len(k) > emojiMaxSize {
                        emojiMaxSize = len(k)
index 65cb98989afa90e48bf396b1c2b0dc4846905190..98005511d84f8721de2f54b44e8fbec525a6795a 100644 (file)
 package helpers
 
 import (
-       "github.com/kyokomi/emoji"
-       "github.com/spf13/hugo/bufferpool"
        "reflect"
        "strings"
        "testing"
+
+       "github.com/kyokomi/emoji"
+       "github.com/spf13/hugo/bufferpool"
 )
 
 func TestEmojiCustom(t *testing.T) {
@@ -25,24 +26,24 @@ func TestEmojiCustom(t *testing.T) {
                input  string
                expect []byte
        }{
-               {"A :smile: a day", []byte(emoji.Sprint("A :smile: a day"))},
-               {"A few :smile:s a day", []byte(emoji.Sprint("A few :smile:s a day"))},
-               {"A :smile: and a :beer: makes the day for sure.", []byte(emoji.Sprint("A :smile: and a :beer: makes the day for sure."))},
-               {"A :smile: and: a :beer:", []byte(emoji.Sprint("A :smile: and: a :beer:"))},
-               {"A :diamond_shape_with_a_dot_inside: and then some.", []byte(emoji.Sprint("A :diamond_shape_with_a_dot_inside: and then some."))},
-               {":smile:", []byte(emoji.Sprint(":smile:"))},
+               {"A :smile: a day", []byte("A πŸ˜„ a day")},
+               {"A few :smile:s a day", []byte("A few πŸ˜„s a day")},
+               {"A :smile: and a :beer: makes the day for sure.", []byte("A πŸ˜„ and a πŸΊ makes the day for sure.")},
+               {"A :smile: and: a :beer:", []byte("A πŸ˜„ and: a πŸΊ")},
+               {"A :diamond_shape_with_a_dot_inside: and then some.", []byte("A πŸ’  and then some.")},
+               {":smile:", []byte("πŸ˜„")},
                {":smi", []byte(":smi")},
-               {"A :smile:", []byte(emoji.Sprint("A :smile:"))},
-               {":beer:!", []byte(emoji.Sprint(":beer:!"))},
-               {"::smile:", []byte(emoji.Sprint("::smile:"))},
-               {":beer::", []byte(emoji.Sprint(":beer::"))},
-               {" :beer: :", []byte(emoji.Sprint(" :beer: :"))},
-               {":beer: and :smile: and another :beer:!", []byte(emoji.Sprint(":beer: and :smile: and another :beer:!"))},
-               {" :beer: : ", []byte(emoji.Sprint(" :beer: : "))},
+               {"A :smile:", []byte("A πŸ˜„")},
+               {":beer:!", []byte("🍺!")},
+               {"::smile:", []byte(":πŸ˜„")},
+               {":beer::", []byte("🍺:")},
+               {" :beer: :", []byte(" πŸΊ :")},
+               {":beer: and :smile: and another :beer:!", []byte("🍺 and πŸ˜„ and another πŸΊ!")},
+               {" :beer: : ", []byte(" πŸΊ : ")},
                {"No smilies for you!", []byte("No smilies for you!")},
                {" The motto: no smiles! ", []byte(" The motto: no smiles! ")},
                {":hugo_is_the_best_static_gen:", []byte(":hugo_is_the_best_static_gen:")},
-               {"은행 :smile: μ€ν–‰", []byte(emoji.Sprint("은행 :smile: μ€ν–‰"))},
+               {"은행 :smile: μ€ν–‰", []byte("은행 πŸ˜„ μ€ν–‰")},
        } {
                result := Emojify([]byte(this.input))