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 format argument to support wrapping of emojis #48

Merged
merged 2 commits into from
Jul 10, 2017
Merged

Add format argument to support wrapping of emojis #48

merged 2 commits into from
Jul 10, 2017

Conversation

smeijer
Copy link

@smeijer smeijer commented Jul 10, 2017

Closes #44


Relevant part of readme update:

format

emoji.emojify(str, onMissing, format);

As third argument, emojify takes an handler to wrap parsed emojis. Provide a function to place emojis in custom elements, and to apply your own styles:

var format = function (code, name) {
  return '<img alt="' + code + '" src="' + name + '.png" />';
});

var emojified = emoji.emojify('I :unknown_emoji: :star: :another_one:', null, format);
// emojified: I <img alt="❤️" src="heart.png" /> <img alt="☕️" src="coffee.png" />

@omnidan
Copy link
Owner

omnidan commented Jul 10, 2017

@smeijer thank you! looks good 👌

@omnidan omnidan merged commit 767cd90 into omnidan:master Jul 10, 2017
@omnidan
Copy link
Owner

omnidan commented Jul 10, 2017

@smeijer actually, I noticed an issue with this - when null is specified as onMissing and a format function is specified, even non-existant emoji are modified.

The question here is which behavior we want. I think it's probably better if the formatting only gets applied to existing emoji and the rest are left alone by default (when onMissing is not defined).

@omnidan
Copy link
Owner

omnidan commented Jul 10, 2017

also see #49

@omnidan omnidan mentioned this pull request Jul 10, 2017
@omnidan
Copy link
Owner

omnidan commented Jul 10, 2017

published 1.7.0 with this merged

@smeijer
Copy link
Author

smeijer commented Jul 12, 2017

Fixed the bug you've mentioned in PR #50

@smeijer smeijer deleted the feature/add-format-option branch July 12, 2017 08:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants