Skip to content

Add format argument to support wrapping of emojis#48

Merged
omnidan merged 2 commits into
omnidan:masterfrom
smeijer:feature/add-format-option
Jul 10, 2017
Merged

Add format argument to support wrapping of emojis#48
omnidan merged 2 commits into
omnidan:masterfrom
smeijer:feature/add-format-option

Conversation

@smeijer

@smeijer smeijer commented Jul 10, 2017

Copy link
Copy Markdown

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

omnidan commented Jul 10, 2017

Copy link
Copy Markdown
Owner

@smeijer thank you! looks good 👌

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

omnidan commented Jul 10, 2017

Copy link
Copy Markdown
Owner

@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

omnidan commented Jul 10, 2017

Copy link
Copy Markdown
Owner

also see #49

@omnidan omnidan mentioned this pull request Jul 10, 2017
@omnidan

omnidan commented Jul 10, 2017

Copy link
Copy Markdown
Owner

published 1.7.0 with this merged

@smeijer

smeijer commented Jul 12, 2017

Copy link
Copy Markdown
Author

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.

2 participants