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

Fix emoji parser for +1 emoji #40

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

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.

@@ -15,7 +15,7 @@ class GFM

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)

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.

3 participants