Skip to content

Conversation

@ghiculescu
Copy link

Kramdown::Document.new("i am :smile: because this PR is :+1:", input: "GFM", gfm_emojis: true).to_html

Fixes a bug where the 😄 emoji is correctly output, but the 👍 is not.

EMOJI_NAMES = Emoji.all.flat_map(&:aliases).freeze
REGISTRY = EMOJI_NAMES.zip(EMOJI_NAMES).to_h.freeze
EMOJI_PATTERN = /:(\w+):/
EMOJI_PATTERN = /:([\w\+]+):/
Copy link

@allisonphillips allisonphillips Jul 5, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not covering 👎🏾 / - is not part of the character class matched by \w, and you shouldn't need to escape + if it's inside of a character class ([ ] \ - ^ are the characters that would need escaping):

Suggested change
EMOJI_PATTERN = /:([\w\+]+):/
EMOJI_PATTERN = /:([\w\-+]+):/

That said, there are a lot of places that don't support +1/-1, they are effectively aliases that were added to gemoji that map to the actual unicode CLDR short names (thumbs up and thumbs down)

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be beneficial to simply rely on an emoji regex gem to supply the regex.
Example: https://github.com/janlelis/unicode-emoji

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.

4 participants