Skip to content

Commit

Permalink
remove before check & always run replace emoticon if enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
AWolf81 committed Mar 17, 2020
1 parent d25c4d1 commit 8aa9eec
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
5 changes: 2 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,9 @@ function plugin(options) {

function transformer(tree) {
visit(tree, 'text', function(node) {
before = node.value;
node.value = before.replace(RE_EMOJI, getEmoji);
node.value = node.value.replace(RE_EMOJI, getEmoji);

if (emoticonEnable && node.value === before) {
if (emoticonEnable) {
// emoji regex not matching --> check if shortcode
node.value = node.value.replace(RE_SHORT, getEmojiByShortCode);
}
Expand Down
2 changes: 1 addition & 1 deletion index_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ describe('remark-emoji', () => {
it('does not replace emoji-like but not-a-emoji stuffs', () => {
const cases = {
'This text does not include emoji.': 'This text does not include emoji.\n',
':++: or :foo: or :dog': ':++: or :foo: or :dog\n',
':++: or :foo: or :cat': ':++: or :foo: or :cat\n',
'::': '::\n'
};

Expand Down

0 comments on commit 8aa9eec

Please sign in to comment.