retext-emoji

retext plugin to support emoji, gemoji, and emoticons

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
retext-emoji
3108.1.02 years ago9 years agoMinified + gzip package size for retext-emoji in KB

Readme

retext-emoji
!Buildbuild-badgebuild !Coveragecoverage-badgecoverage !Downloadsdownloads-badgedownloads !Sizesize-badgesize !Sponsorssponsors-badgecollective !Backersbackers-badgecollective !Chatchat-badgechat
retextretext plugin to support emoji, gemoji, and emoticons.

Install

This package is ESM only: Node 12+ is needed to use it and it must be imported instead of required.
npm install retext-emoji
## Use

```js
import retext from 'retext'
import emoji from 'retext-emoji'

const file = retext()
  .use(emoji, {convert: 'encode'})
  .processSync('I’m going to bed. :zzz:')

console.log(String(file))

Yields:
I’m going to bed. 💤

API

This package exports no identifiers. The default export is retextEmoji.

unified().use(retextEmoji[, options])

Support emoji, gemoji, and emoticons.
options.convert
If, and how to convert ('encode' or 'decode', optional).
When encode is given, converts short-codes and emoticons to their unicode equivalent (:heart: and <3 to ❤️).
When decode is given, converts unicode emoji and emoticons to their short-code equivalent (❤️ and <3 to :heart:).

EmoticonNode

retext-emoji adds a new node to nlcstnlcst: Emoticon (Literalliteral).
Whether emoji (❤️), emoticon (<3), or gemoji (:heart:), all are classified as EmoticonNodes.
interface Emoticon < Symbol {
  type: "EmoticonNode"
  data: EmoticonData
}

interface EmoticonData {
  emoji: string
  names: [string]
  description: string?
  tags: [string]
}

Support

retext-emoji supports every gemojigemoji and every emoticonemoticon.

Contribute

See contributing.mdcontributing in retextjs/.githubhealth for ways to get started. See support.mdsupport for ways to get help.
This project has a Code of Conductcoc. By interacting with this repository, organisation, or community you agree to abide by its terms.

License

MITlicense © Titus Wormerauthor