-
-
Notifications
You must be signed in to change notification settings - Fork 7.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add emoji support #1892
Add emoji support #1892
Conversation
82dbc4d
to
31a238d
Compare
c0f259e
to
3bc3ae2
Compare
e691130
to
d3f754e
Compare
|
||
See the [Emoji cheat sheet](http://www.emoji-cheat-sheet.com/) for available emoticons. | ||
|
||
e.g. `{{ .Title | emojify }}` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about this example instead?
{{ "I :heart: Hugo" | emojify }}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Me like.
This uses the Emoji map from https://github.com/kyokomi/emoji -- but with a custom replacement implementation. The built-in are fine for most use cases, but in Hugo we do care about pure speed. The benchmarks below are skewed in Hugo's direction as the source and result is a byte slice, Kyokomi's implementation works best with strings. Curious: The easy-to-use `strings.Replacer` is also plenty fast. ``` BenchmarkEmojiKyokomiFprint-4 20000 86038 ns/op 33960 B/op 117 allocs/op BenchmarkEmojiKyokomiSprint-4 20000 83252 ns/op 38232 B/op 122 allocs/op BenchmarkEmojiStringsReplacer-4 100000 21092 ns/op 17248 B/op 25 allocs/op BenchmarkHugoEmoji-4 500000 5728 ns/op 624 B/op 13 allocs/op ``` Fixes gohugoio#1891
@moorereason I have adjusted re your comments. Please merge if you think it looks OK. |
👍 Merged in cafb784. |
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
This uses the Emoji map from https://github.com/kyokomi/emoji -- but with a custom replacement implementation.
The built-in are fine for most use cases, but in Hugo we do care about pure speed.
The benchmarks below are skewed in Hugo's direction as the source and result is a byte slice,
Kyokomi's implementation works best with strings.
Curious: The easy-to-use
strings.Replacer
is also plenty fast.Fixes #1891