mirror of
https://github.com/gohugoio/hugo.git
synced 2024-11-07 20:30:36 -05:00
parent
683888ebc8
commit
2564f46a68
2 changed files with 11 additions and 6 deletions
|
@ -51,14 +51,11 @@ func Emojify(source []byte) []byte {
|
||||||
}
|
}
|
||||||
|
|
||||||
endEmoji := bytes.Index(source[j+1:upper], emojiDelim)
|
endEmoji := bytes.Index(source[j+1:upper], emojiDelim)
|
||||||
|
|
||||||
if endEmoji < 0 {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
|
|
||||||
nextWordDelim := bytes.Index(source[j:upper], emojiWordDelim)
|
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
|
start += endEmoji + 1
|
||||||
} else {
|
} else {
|
||||||
endKey := endEmoji + j + 2
|
endKey := endEmoji + j + 2
|
||||||
|
|
|
@ -44,7 +44,15 @@ func TestEmojiCustom(t *testing.T) {
|
||||||
{" The motto: no smiles! ", []byte(" The motto: no smiles! ")},
|
{" The motto: no smiles! ", []byte(" The motto: no smiles! ")},
|
||||||
{":hugo_is_the_best_static_gen:", []byte(":hugo_is_the_best_static_gen:")},
|
{":hugo_is_the_best_static_gen:", []byte(":hugo_is_the_best_static_gen:")},
|
||||||
{"은행 :smile: 은행", []byte("은행 😄 은행")},
|
{"은행 :smile: 은행", []byte("은행 😄 은행")},
|
||||||
|
// #2198
|
||||||
|
{"See: A :beer:!", []byte("See: A 🍺!")},
|
||||||
|
{`Aaaaaaaaaa: aaaaaaaaaa aaaaaaaaaa aaaaaaaaaa.
|
||||||
|
|
||||||
|
:beer:`, []byte(`Aaaaaaaaaa: aaaaaaaaaa aaaaaaaaaa aaaaaaaaaa.
|
||||||
|
|
||||||
|
🍺`)},
|
||||||
} {
|
} {
|
||||||
|
|
||||||
result := Emojify([]byte(this.input))
|
result := Emojify([]byte(this.input))
|
||||||
|
|
||||||
if !reflect.DeepEqual(result, this.expect) {
|
if !reflect.DeepEqual(result, this.expect) {
|
||||||
|
|
Loading…
Reference in a new issue