From 26906d856916a27456f699dd2494bd796c025837 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Pedersen?= Date: Mon, 9 May 2016 22:59:49 +0200 Subject: [PATCH] Don't add any space around Emojis --- helpers/emoji.go | 5 +++-- helpers/emoji_test.go | 33 +++++++++++++++++---------------- 2 files changed, 20 insertions(+), 18 deletions(-) diff --git a/helpers/emoji.go b/helpers/emoji.go index ad6737878..3b0b1605f 100644 --- a/helpers/emoji.go +++ b/helpers/emoji.go @@ -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) diff --git a/helpers/emoji_test.go b/helpers/emoji_test.go index 65cb98989..98005511d 100644 --- a/helpers/emoji_test.go +++ b/helpers/emoji_test.go @@ -13,11 +13,12 @@ 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))