Skip to content

Commit b3fa92d

Browse files
feat: use unicode emoji! (#868)
| [![PR App][icn]][demo] | Fix RM-9354 | | :--------------------: | :---------: | ## 🧰 Changes Uses the unicode emoji! I notice `@readem/emojis` doesn't index aliases. And rather than update the package, I've swapped out our png's for unicode for the majority of them. It still falls back to our custom emoji package when necessary.
1 parent 85d63c5 commit b3fa92d

File tree

17 files changed

+114
-50
lines changed

17 files changed

+114
-50
lines changed

Dockerfile

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@ COPY . ./
2525

2626
RUN mkdir -p __tests__/browser/__image_snapshots__/__diff_output__
2727

28-
RUN make emojis
29-
3028
EXPOSE 9966
3129

3230
CMD ["test.browser"]

Dockerfile.legacy

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,6 @@ COPY . ./
3232

3333
RUN mkdir -p __tests__/browser/__image_snapshots__/__diff_output__
3434

35-
RUN make emojis
36-
3735
EXPOSE 9966
3836

3937
CMD ["test.browser"]

Makefile

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,6 @@ DOCKER_WORKSPACE := "/markdown"
66
MOUNTS = --volume ${PWD}:${DOCKER_WORKSPACE} \
77
--volume ${DOCKER_WORKSPACE}/node_modules
88

9-
emojis: example/public/img/emojis ## Install our emojis.
10-
11-
example/public/img/emojis: node_modules/@readme/emojis
12-
rm -rf example/img/emojis
13-
rm -rf example/public/img/emojis
14-
mkdir -p example/public/img/emojis
15-
cp node_modules/@readme/emojis/src/img/*.png example/public/img/emojis/
16-
179
ifeq ($(USE_LEGACY), true)
1810
dockerfile = -f Dockerfile.legacy
1911
endif

__tests__/__snapshots__/index.test.js.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ Object {
7373
`;
7474
7575
exports[`emojis 1`] = `
76-
"<p><img alt=\\":joy:\\" loading=\\"lazy\\" src=\\"/public/img/emojis/joy.png\\" title=\\":joy:\\" class=\\"emoji\\" align=\\"absmiddle\\" height=\\"20\\" width=\\"20\\" caption=\\"\\"><br>
76+
"<p>😂<br>
7777
<i class=\\"fa fa-lock\\"></i><br>
7878
:unknown-emoji:</p>"
7979
`;
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { mdast, md } from '../../index';
2+
3+
describe('gemoji compiler', () => {
4+
it('writes an gemojis back to shortcodes', () => {
5+
const doc = ':poop:';
6+
const tree = mdast(doc);
7+
8+
expect(md(tree)).toMatch(doc);
9+
});
10+
});

__tests__/gemoji-parser.test.js

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,35 @@ const unified = require('unified');
33

44
const parser = require('../processor/parse/gemoji-parser');
55

6-
test('should output an image node for a known emoji', () => {
6+
test('should output emoji', () => {
77
const emoji = 'joy';
88
const markdown = `This is a gemoji :${emoji}:.`;
9+
const ast = {
10+
type: 'root',
11+
children: [
12+
{
13+
type: 'paragraph',
14+
children: [
15+
{ type: 'text', value: 'This is a gemoji ' },
16+
{
17+
type: 'gemoji',
18+
value: '😂',
19+
name: emoji,
20+
},
21+
{ type: 'text', value: '.' },
22+
],
23+
},
24+
],
25+
};
26+
27+
expect(unified().use(remarkParse).use(parser).data('settings', { position: false }).parse(markdown)).toStrictEqual(
28+
ast,
29+
);
30+
});
31+
32+
test('should output an image node for a custom readme emoji', () => {
33+
const emoji = 'owlbert';
34+
const markdown = `This is a gemoji :${emoji}:.`;
935
const ast = {
1036
type: 'root',
1137
children: [
3.67 KB
Loading

assets/img/emojis/owlbert-mask.png

3.52 KB
Loading
3 KB
Loading
3.14 KB
Loading

0 commit comments

Comments
 (0)