hugo

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

git clone git://git.shimmy1996.com/hugo.git
commit 2564f46a685704c459bec5d0100f5111c138c9b4
parent 683888ebc89049d69042cdc5dc224884cd7903df
Author: Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Date:   Sat, 11 Jun 2016 20:40:56 +0200

Fix Emojfy for certain text patterns

Fixes #2198

Diffstat:
Mhelpers/emoji.go | 9+++------
Mhelpers/emoji_test.go | 8++++++++
2 files changed, 11 insertions(+), 6 deletions(-)
diff --git a/helpers/emoji.go b/helpers/emoji.go
@@ -51,14 +51,11 @@ func Emojify(source []byte) []byte {
 		}
 
 		endEmoji := bytes.Index(source[j+1:upper], emojiDelim)
-
-		if endEmoji < 0 {
-			break
-		}
-
 		nextWordDelim := bytes.Index(source[j:upper], emojiWordDelim)
 
-		if endEmoji == 0 || (nextWordDelim != -1 && nextWordDelim < endEmoji) {
+		if endEmoji < 0 {
+			start += upper + 1
+		} else if endEmoji == 0 || (nextWordDelim != -1 && nextWordDelim < endEmoji) {
 			start += endEmoji + 1
 		} else {
 			endKey := endEmoji + j + 2
diff --git a/helpers/emoji_test.go b/helpers/emoji_test.go
@@ -44,7 +44,15 @@ func TestEmojiCustom(t *testing.T) {
 		{" The motto: no smiles! ", []byte(" The motto: no smiles! ")},
 		{":hugo_is_the_best_static_gen:", []byte(":hugo_is_the_best_static_gen:")},
 		{"은행 :smile: 은행", []byte("은행 😄 은행")},
+		// #2198
+		{"See: A :beer:!", []byte("See: A 🍺!")},
+		{`Aaaaaaaaaa: aaaaaaaaaa aaaaaaaaaa aaaaaaaaaa.
+
+:beer:`, []byte(`Aaaaaaaaaa: aaaaaaaaaa aaaaaaaaaa aaaaaaaaaa.
+
+🍺`)},
 	} {
+
 		result := Emojify([]byte(this.input))
 
 		if !reflect.DeepEqual(result, this.expect) {