Skip to content

Commit 2df077c

Browse files
fix: emoji context (#1190)
| [![PR App][icn]][demo] | RM-13827 | | :--------------------: | :------: | ## 🧰 Changes Prevents rendering gemoji's unless preceded by a space or at the start of a line. ## 🧬 QA & Testing - [Broken on production][prod]. - [Working in this PR app][demo]. [demo]: https://markdown-pr-PR_NUMBER.herokuapp.com [prod]: https://SUBDOMAIN.readme.io [icn]: https://user-images.githubusercontent.com/886627/160426047-1bee9488-305a-4145-bb2b-09d8b757d38a.svg **BREAKING CHANGE**: Changes how emoji's are parsed in markdown.
1 parent 76b0492 commit 2df077c

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

__tests__/parsers/gemoji.test.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,4 +61,12 @@ describe('gemoji parser', () => {
6161

6262
expect(mdast(markdown).children[0].children[0].value).toMatch(/:unknown-emoji:/);
6363
});
64+
65+
const beforeTests = ['letter', '1', '.', ':', "'", '!', '?', ',', ';', '(', '[', ')', ']', '}'];
66+
67+
it.each(beforeTests)('should not render an emoji following a "%s"', string => {
68+
const tree = mdast(`${string}:joy:`);
69+
70+
expect(tree.children[0].children[0].value).toBe(`${string}:joy:`);
71+
});
6472
});

processor/transform/gemoji+.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { findAndReplace } from 'mdast-util-find-and-replace';
66
import { NodeTypes } from '../../enums';
77
import Owlmoji from '../../lib/owlmoji';
88

9-
const regex = /:(?<name>\+1|[-\w]+):/g;
9+
const regex = /(?<=^|\s):(?<name>\+1|[-\w]+):/g;
1010

1111
const gemojiReplacer = (_, name: string) => {
1212
switch (Owlmoji.kind(name)) {

0 commit comments

Comments
 (0)