🤷♂️ Emoji Guy
A NPM package to parse the emoji shortcodes for showing in HTML. Currently supporting the SLACK emojis, more on the way.
Installing
- Using npm:
$ npm i emojiguy
- Using yarn:
$ yarn add emojiguy
Usage
- Import the package
const emojiguy = require('emojiguy');
- Parse a text for HTML
const text = 'Hello everyone :man-raising-hand:. Good morning! :smile:';
const parsedText = emojiguy.parseForSlack(text, { separateTag: true });
console.log(parsedText);
// Hello everyone <span>🙋</span>. Good morning! <span>😄</span>
Methods
parseForSlack(text[, {separteTag}])
For replacing the emoji short codes with HTML codes. The returned text can be directly used in HTML document.
- separteTag = false
const text = 'Hello everyone :man-raising-hand:. Good morning! :smile:';
let parsedText = emojiguy.parseForSlack(text);
console.log(parsedText);
// Hello everyone 🙋. Good morning! 😄
- separteTag = true
const text = 'Hello everyone :man-raising-hand:. Good morning! :smile:';
let parsedText = emojiguy.parseForSlack(text, { separateTag: true });
console.log(parsedText);
// Hello everyone <span>🙋</span>. Good morning! <span>😄</span>
getHtmlCode(shortcode)
For getting the html code for a specific emoji short code.
console.log(emojiguy.getHtmlCode('low_battery'));
// 🪫
console.log(emojiguy.getHtmlCode(':low_battery:'));
// 🪫
Issues
If you encounter any issue while using the package please report it here