Skip to main content

Emoji notation expansion.

Project description

:sparkles::syringe::sparkles: inject-emoji
==========================================

|Build Status|

A simple script to replace `emoji <http://emoji-cheat-sheet.com>`__
string notation such as ``:simple_smile:`` with an HTML image tag. By
default, ``inject-emoji`` reads from ``STDIN``, and writes to
``STDOUT``.

About
-----

So many offline GitHub Flavored Markdown renderers, yet so few with
GitHub Flavored Markdown Emoji. Until now.

The Interface
~~~~~~~~~~~~~

``inject-emoji`` is available both as a Python module and a command-line
application (powered by Python).

The Python Module
^^^^^^^^^^^^^^^^^

***injectemoji.InjectEmoji([Input FileObj], [Output FileObj],
[emoji\_directory])*** If input and/or output FileObjects are provided,
they will be used accordingly. If none are provided, ``sys.stdin`` and
``sys.stdout``, respectively, will be used. If an emoji directory (say,
from your own checkout of
`WebpageFX/emoji-cheat-sheet.com <https://github.com/WebpageFX/emoji-cheat-sheet.com/>`__),
the substitutions provided to the regular expression in ``inject-emoji``
will be a reflection of the filenames in that directory.

The CLI Tool
^^^^^^^^^^^^

.. code:: text

usage: inject-emoji [-h] [-o FILE] [-d EMOJI_DIR] [FILE]

Convert emoji-cheat-sheet notation to HTML image tags.

positional arguments:
FILE Read from FILE instead of stdin

optional arguments:
-h, --help show this help message and exit
-o FILE, --output FILE
Write to FILE instead of stdout
-d EMOJI_DIR, --dir EMOJI_DIR
Read emoji directory listing from EMOJI_DIR instead of
bundled emoji

The Installation
~~~~~~~~~~~~~~~~

::

$ pip install inject-emoji

The RegEx
~~~~~~~~~

The regular expression match is Python-flavored. The shorthand view of
it is:

::

(?<!`)(:([\-\+a-z0-9_]+):)(?!`)

.. figure:: https://raw.githubusercontent.com/claylo/inject-emoji/master/media/mR9lztEVrnVQB463.png
:alt: Regular expression visualization

Regular expression visualization

`Debuggex Demo <https://www.debuggex.com/r/mR9lztEVrnVQB463>`__

However, in the source itself, all 800+ emoji names are compiled into
the regex.

The Why
~~~~~~~

I wrote this script to enhance Github Flavored Markdown generated by
`Marked 2 <http://marked2app.com>`__. To use it with Marked 2, configure
it as a preprocessor like so:

.. figure:: https://raw.githubusercontent.com/claylo/inject-emoji/master/media/preprocessor-marked2.png
:alt: Marked 2 Config

Marked 2 Config

.. |Build Status| image:: https://travis-ci.org/claylo/inject-emoji.svg?branch=master
:target: https://travis-ci.org/claylo/inject-emoji

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

inject-emoji-1.0.0.tar.gz (3.9 MB view details)

Uploaded Source

Built Distribution

inject_emoji-1.0.0-py2.py3-none-any.whl (13.3 kB view details)

Uploaded Python 2Python 3

File details

Details for the file inject-emoji-1.0.0.tar.gz.

File metadata

  • Download URL: inject-emoji-1.0.0.tar.gz
  • Upload date:
  • Size: 3.9 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for inject-emoji-1.0.0.tar.gz
Algorithm Hash digest
SHA256 001ba90696faeabb380b8ff4881374802768b6255a27b8f6ff7e7f87b9c81f3e
MD5 c5ec8aabb652ce941ccf0ff2550eca6e
BLAKE2b-256 65631c637f704dd04b03a1723b847948b91ab56a61a23fdc61d5bf40f3136a37

See more details on using hashes here.

File details

Details for the file inject_emoji-1.0.0-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for inject_emoji-1.0.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 aa6ccaeea5bf2e2a57bbad0215186612dda1ddc6a785c10f37af0f5efbd5f126
MD5 7016626c4b57c3d65821d1b8eecebe2d
BLAKE2b-256 890d246ecf9db2b71598430a870482021d3d093d794f8f6102a7f7f02dc1eef3

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page