Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 1,000,000+ packages pre-installed, including smile-parser with all npm packages installed. Try it out:

var smileParser = require("smile-parser")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

smile-parser v0.2.1

Emoji parser written in javascript

Build Status

smile-parser

Greenkeeper badge This is a small library which takes a string, parses emojis out and replaces them with html image tags and returns the string.

Parses emojis from given string with syntax:

  • :emoji:
  • :emoji::skin-tone-2:
  • :) :/ :( :'( :| ;) :D :P :o <-- These emojis require a start or end of string or space before or after to work, this is to avoid messing up url's for example

Supports only apple emojis hosted separately. Emoji-data comes from iamcal/emoji-data repository so huge thanks for him!

Usage

  • Install and require the package
  • Define options for the smile-parser
const emojiOpts = {
  url: https://demo.url/emojis/,
  styles: "height: 21px; position: relative;"
}
  • you need to host emojis somewhere and give the url to emoji folder in options

  • Run smileParse to a string you wish to parse

smileParse(string, emojiOpts)

Commands

  • npm run test - Runs all the test
  • npm run build - Compiles the code
  • npm run compile-emoji minifies new emoji-data to include only necessary fields

Todo:

  • Support sprites
  • Create a demo page
  • Support other emoji-libraries
  • Finish this readme

License

MIT see LICENSE.md for details.

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free