Git Product home page Git Product logo

emoji-transmogrifier's Introduction

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

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

Contributing

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

License

MIT

emoji-transmogrifier's People

Contributors

dependabot-preview[bot] avatar dependabot[bot] avatar edm00se avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar

emoji-transmogrifier's Issues

The automated release is failing 🚨

🚨 The automated release from the master branch failed. 🚨

I recommend you give this issue a high priority, so other packages depending on you could benefit from your bug fixes and new features.

You can find below the list of errors reported by semantic-release. Each one of them has to be resolved in order to automatically publish your package. I’m sure you can resolve this πŸ’ͺ.

Errors are usually caused by a misconfiguration or an authentication problem. With each error reported below you will find explanation and guidance to help you to resolve it.

Once all the errors are resolved, semantic-release will release your package the next time you push a commit to the master branch. You can also manually restart the failed CI job that runs semantic-release.

If you are not sure how to resolve this, here is some links that can help you:

If those don’t help, or if this issue is reporting something you think isn’t right, you can always ask the humans behind semantic-release.


Invalid npm token.

The npm token configured in the NPM_TOKEN environment variable must be a valid token allowing to publish to the registry https://registry.npmjs.org/.

If you are using Two-Factor Authentication, make configure the auth-only level is supported. semantic-release cannot publish with the default auth-and-writes level.

Please make sure to set the NPM_TOKEN environment variable in your CI with the exact value of the npm token.


Good luck with your project ✨

Your semantic-release bot πŸ“¦πŸš€

Duplicating URL Value

The href via the cli tool is duplicating info in the build-out, should just pass-through the href value.

Sec Dep Bump

Bump sub-dependencies to address sec vulnerability.

Add Globbing vs Params for Directory and File Extension

Currently, the cli zap action requires params of -d/--directory and -t/--type (defaults to ./ and md). It would be preferable to switch to an easier to use file globbing pattern, a la node-glob; this is the mechanic used by grunt or gulp and should be familiar to anyone accustomed to node dev (and node tools).

CLI Broke

Pointer to main.js failing πŸ˜•.

Feature: Support for flag-XX Emojis

Provide flag-XX Style Support

With -xx being the two-letter country code identifiers. This should match the same as any other short codes.

Reference this reported issue, #19.

Requires:

  • unicode combinations (pairs, in this case)
  • image sources that can be made similar to the others in use
  • full support of ranges and named short codes, a la GitHub (this means country/region code, not flag-), and this is good to go now

Expand CLI to Completed Use of Server Module

Including functionality with getting the unicode or url. Should also preserve, under separate command namespace, the existing scan and replace (transmogrification) provided to-date by cli.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.