Skip to content

Commit

Permalink
wrapEmoji should ignore all non-unicode (#41)
Browse files Browse the repository at this point in the history
  • Loading branch information
pauldps committed May 3, 2024
1 parent 87898fd commit 7a6ebf3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export const STRIP_RX = new RegExp('{(?:' + COLORS + '|/)}', 'gim')
/**
* RegExp to wrap all emoji in <span> tags.
*/
export const EMOJI_RX = /([\p{Emoji}\p{Emoji_Presentation}]+)/gimsu
export const EMOJI_RX = /([\p{Emoji_Presentation}]+)/gu

/**
* Template to use when replacing emoji.
Expand Down
6 changes: 5 additions & 1 deletion test/wrapEmoji.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ describe('#wrapEmoji', function () {
})

it('does not affect non-emoji', function () {
expect(wrapEmoji('abcπŸ˜…def')).to.eq('abc<span class="wmE">πŸ˜…</span>def')
expect(wrapEmoji('123abcπŸ˜…def456#*')).to.eq('123abc<span class="wmE">πŸ˜…</span>def456#*')
})

it('tags all emojis', function () {
Expand All @@ -25,4 +25,8 @@ describe('#wrapEmoji', function () {
it('tags sequential emojis in a single tag', function () {
expect(wrapEmoji('abc πŸ˜‚πŸ’―πŸ˜… def')).to.eq('abc <span class="wmE">πŸ˜‚πŸ’―πŸ˜…</span> def')
})

it('breaks down sequential emojis split by multiline', function () {
expect(wrapEmoji('abc πŸ˜‚\nπŸ’―πŸ˜… def')).to.eq('abc <span class="wmE">πŸ˜‚</span>\n<span class="wmE">πŸ’―πŸ˜…</span> def')
})
})

0 comments on commit 7a6ebf3

Please sign in to comment.