hugo

Unnamed repository; edit this file 'description' to name the repository.

git clone git://git.shimmy1996.com/hugo.git
commit b6635e1bafecb0a0f203c9ac9672c99ef1a6fa71
parent 7cb8107735d8612a26ad95dfdec2141b0e0e6baa
Author: Cameron Moore <moorereason@gmail.com>
Date:   Mon, 29 Aug 2016 17:34:48 -0500

helpers: Fix bug in emoji renderer

Fixes #2391
Diffstat:
Mhelpers/emoji.go | 4+---
Mhelpers/emoji_test.go | 7++++++-
2 files changed, 7 insertions(+), 4 deletions(-)
diff --git a/helpers/emoji.go b/helpers/emoji.go
@@ -34,7 +34,6 @@ var (
 // Note that the input byte slice will be modified if needed.
 // See http://www.emoji-cheat-sheet.com/
 func Emojify(source []byte) []byte {
-
 	emojiInit.Do(initEmoji)
 
 	start := 0
@@ -54,7 +53,7 @@ func Emojify(source []byte) []byte {
 		nextWordDelim := bytes.Index(source[j:upper], emojiWordDelim)
 
 		if endEmoji < 0 {
-			start += upper + 1
+			start += 1
 		} else if endEmoji == 0 || (nextWordDelim != -1 && nextWordDelim < endEmoji) {
 			start += endEmoji + 1
 		} else {
@@ -76,7 +75,6 @@ func Emojify(source []byte) []byte {
 	}
 
 	return source
-
 }
 
 func initEmoji() {
diff --git a/helpers/emoji_test.go b/helpers/emoji_test.go
@@ -53,12 +53,17 @@ func TestEmojiCustom(t *testing.T) {
 
 šŸŗ`)},
 		{"test :\n```bash\nthis is a test\n```\n\ntest\n\n:cool::blush:::pizza:\\:blush : : blush: :pizza:", []byte("test :\n```bash\nthis is a test\n```\n\ntest\n\nšŸ†’šŸ˜Š:šŸ•\\:blush : : blush: šŸ•")},
+		{
+			// 2391
+			"[a](http://gohugo.io) :smile: [r](http://gohugo.io/introduction/overview/) :beer:",
+			[]byte(`[a](http://gohugo.io) šŸ˜„ [r](http://gohugo.io/introduction/overview/) šŸŗ`),
+		},
 	} {
 
 		result := Emojify([]byte(this.input))
 
 		if !reflect.DeepEqual(result, this.expect) {
-			t.Errorf("[%d] got '%q' but expected %q", i, result, this.expect)
+			t.Errorf("[%d] got %q but expected %q", i, result, this.expect)
 		}
 
 	}