rhysd / remark-emoji

Remark markdown transformer to replace :emoji: in text
MIT License
121 stars 17 forks source link

[Feature Request] Custom emoji support #30

Open guoyunhe opened 8 months ago

guoyunhe commented 8 months ago

In many forum and chat apps, you are able to create your own emojis, like

Parrot

And you can have your own short code:

:parrot:

Configuration will be like:

remark().use(emoji, {
  customEmojis: {
    parrot: '![Parrot](https://cultofthepartyparrot.com/parrots/parrot.gif)'
  }
});
rhysd commented 5 months ago

I reopened this issue ticket since #31 was reverted.

rhysd commented 5 months ago

Since remark is essentially a transformation from Markdown AST to HTML AST, it is difficult to provide APIs which allow to specify raw Markdown or HTML sources (if we do, we need to parse the sources into AST nodes in advance).

Configuration like below would be easier, but I'm not sure it is useful (since I don't have use case to provide custom emoijs).

remark().use(emoji, {
  customEmojis: {
    parrot: {
      src: 'https://cultofthepartyparrot.com/parrots/parrot.gif', // "src" of <img> (requried)
      aria: 'rainbow parrot', // aria label for accessibility (optional)
    }
  }
});
chad3814 commented 3 months ago

I created a new PR #32 that has custom emoji support. I plan to use this in my web game.