npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

emoji-transmogrifier

v4.0.0

Published

a handy little library for converting emoji short codes to html image tags

Downloads

25

Readme

emoji-transmogrifier

NPM version NPM downloads Build Status Dependency Status Codecov Codacy Badge semantic-release npm

A handy little library (written as a Node.js module) for converting emoji short codes into HTML image tags. This is mostly a project to force myself to go through all the steps of creating a Node module.

Transmogrifier

Calvin and Hobbes

Installation

NPM

Globally

$ npm install -g emoji-transmogrifier

Usage

Using the module is currently available from the command line as a brief utility to autmoate the conversion of the short code strings in markdown or html files and for traditional Node module consumption (aka- via a require() statement).

CLI Utility

The command line tool now has the previous functionality under the zap command and provides the server module's getImage and getUnicode functionality exposed by the unicode (or uni) and url (or href) commands, respectively. The zap command keeps the same -d (or --directory) and -t (or --type) as before, but will default to the current directory and markdown files ending in .md.

For specifics about a give command, invoke the command followed by -h, such as emoji-transmogrifier zap -h.

  Usage: emoji-transmogrifier <cmd>


  Commands:

    zap   			convert emoji short codes in specified files (globbing pattern, defaults to `**/*.md`) to image tags
    unicode|uni     returns the unicode interpretation of the given emoji short code
    url|href        returns the GitHub url of the given emoji by short code

  Options:

    -h, --help  output usage information

Server Module

var transmogrifier = require('emoji-transmogrifier');

var beerEmojiUrl = transmogrifier.getImage('beer');
console.log('the url of the GitHub emoji image for beer is: '+beerEmojiUrl);

var beerUniStr = transmogrifier.getUnicode('beer');
console.log('the unicode string for beer is: '+beerUniStr);

History

This project was born from the need I had to convert the emoji short codes, a la :smile:, to an HTML image tag, for use with a book I'm writing with gitbook. The web static version generated by gitbook was fine with some scripts I had injected to handle them, but ran into issues when generating the pdf, mobi, or epub versions of the book, yielding the original short code text. This project is the next evolutionary version of the script I created to perform the conversion.

RegEx Pattern

At the heard of this task is a regular expression that performs the matching of the short code which is to be replaced.

The RegEx pattern I settled on can be viewed and tested against the known emoji short codes by viewing the pattern here: https://regex101.com/r/hI5qF5/1

The pattern itself:

/(\:(\w|\+|\-)+\:)(?=\s|[\!\.\?]|$)/gim

Road Map

  • [x] complete coveralls implementation
  • [x] add alternate cli function of exposing the internal methods to the 'server' module
    • [x] provide return of image path (href)
    • [x] provide return of unicode string
  • [x] provide current conversion function ability to traverse subdirectories
  • [x] add range support, as discussed in #20

Contributing

Please consult and follow the contribution guide prior to submitting any Pull Requests.

License

MIT