Skip to content

Commit

Permalink
Merge branch 'next'
Browse files Browse the repository at this point in the history
  • Loading branch information
kellyjosephprice committed Sep 12, 2024
2 parents ceaf3aa + a1e2d82 commit 535ccf9
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
12 changes: 12 additions & 0 deletions __tests__/compilers/gemoji.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,16 @@ describe('gemoji compiler', () => {

expect(mdx(mdast(markdown)).trimEnd()).toEqual(markdown);
});

it('should compile owlmoji back to a shortcode', () => {
const markdown = `:owlbert:`;

expect(mdx(mdast(markdown)).trimEnd()).toEqual(markdown);
});

it('should compile font-awsome emojis back to a shortcode', () => {
const markdown = `:fa-readme:`;

expect(mdx(mdast(markdown)).trimEnd()).toEqual(markdown);
});
});
8 changes: 7 additions & 1 deletion processor/transform/readme-to-mdx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,13 @@ const readmeToMdx = (): Transform => tree => {
if ('url' in image) image.data.hProperties.src = image.url;
const attributes = toAttributes(image.data.hProperties, imageAttrs);

if (hasExtra(attributes)) {
if (image.data.hProperties.className === 'emoji') {
parent.children.splice(index, 1, {
type: NodeTypes.emoji,
name: image.title.replace(/^:(.*):$/, '$1'),
value: image.title,
});
} else if (hasExtra(attributes)) {
parent.children.splice(index, 1, {
type: 'mdxJsxFlowElement',
name: 'Image',
Expand Down

0 comments on commit 535ccf9

Please sign in to comment.