Skip to content
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 emojis support #1891

Closed
bep opened this issue Feb 24, 2016 · 10 comments
Closed

Add emojis support #1891

bep opened this issue Feb 24, 2016 · 10 comments

Comments

@bep
Copy link
Member

bep commented Feb 24, 2016

See the update task here for inspiration for a go generate task:

https://github.com/Ranks/emojify.js/blob/master/gulpfile.js

The images´ license looks complicated:

https://github.com/arvida/emoji-cheat-sheet.com/blob/master/LICENSE

Not sure if there are any options here.

It could hook nicely into the transformer chain, maybe. Not sure how be should bundle the images.

Should have a flag, default off.

@digitalcraftsman
Copy link
Member

kyokomi/emoji seems to be a lightweight Go implementation for printing emojis.

@bep
Copy link
Member Author

bep commented Feb 24, 2016

Thanks, @digitalcraftsman - I have tested that one in Hugo (see PR in progress) and it only partially works in my tests ... And it is not very efficient the way it is done now, but that can be fixed ... Will have a look at it ... later.

@bep
Copy link
Member Author

bep commented Feb 25, 2016

Maybe this is better to do directly with the content files.

@bep
Copy link
Member Author

bep commented Feb 25, 2016

OK, I found the issue now ... that emoji gets confused if you have colon ( : ) in your text ...

kyokomi/emoji#4

@digitalcraftsman
Copy link
Member

That was a fast bugfix. I think it would also make sense to add a template function, something like emojify.

@bep
Copy link
Member Author

bep commented Mar 2, 2016

Another issue in that library: kyokomi/emoji#6

It doesn't matter too much for us as I'm rewriting the replacement part of it to fit Hugo, but I use that library as a facit in my tests.

bep added a commit to bep/hugo that referenced this issue Mar 11, 2016
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
@yangwao
Copy link

yangwao commented Mar 13, 2016

Thanks!

@yangwao
Copy link

yangwao commented Mar 14, 2016

@bep do I need enable something for templating functions? Looks like templating doesn't work for me.
like for example {{ "cat" | pluralize }} doesn't work for me, it just prints {{ "cat" | pluralize }}

I have Hugo Static Site Generator v0.16-DEV BuildDate: 2016-03-13T08:10:03+01:00

@bep
Copy link
Member Author

bep commented Mar 14, 2016

@yangwao please use http://discuss.gohugo.io/ for questions.

@anthonyfok anthonyfok modified the milestone: v0.16 Apr 20, 2016
tychoish pushed a commit to tychoish/hugo that referenced this issue Aug 13, 2017
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
@github-actions
Copy link

github-actions bot commented Apr 7, 2022

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 7, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants