Skip to main content

A Python implementation of a concept of using fallback images, alt text, title text and aria labels to represent emoji in HTML code in a more accessible method.

Project description

Emojificate is a Python implementation of a concept of using fallback images, alt text, title text and aria labels to represent emoji in HTML code in a more accessible method.

Usage

To convert a string from the command line:

$ python3 -m emojificate "I 💜 emoji 😊"
I <img src="https://twemoji.maxcdn.com/36x36/1f49c.png" alt="💜" title="Purple Heart"
aria-label="Emoji: Purple Heart"> emoji <img src="https://twemoji.maxcdn.com/36x36/1f60a.png"
alt="😊" title="Smiling Face With Smiling Eyes" aria-label="Emoji: Smiling Face With Smiling Eyes">

Or, if you’ve got a Django project, put emojificate into your INSTALLED_APPS, and then use the following in a template:

{% load emojificate %}
This is some {{ user_content|emojificate }} that has emoji in it.

{% emojified %}
This is some template content that 💜 emoji as well.
{% endemojified %}

Implementation

TL;DR: Take a string, split it into token, and if a token is emoji, process it into a nice format.

Splitting the string is a problem, because at the moment it does not handle Zero Width Joining sequences. However, native Python string tokenization does work for the most part.

Given a list of tokens, we can leverage the native unicodedata to:

  • see if a token is a unicode Symbol (an emoji)

  • get the codepoint for the emoji, and

  • get the name of the emoji

>From there, we construct an <img> replacement for the emoji:

  • Use images from twemoji, Twitter’s emoji set

  • Have an alt parameter containing the original emoji. This allows for copying-pasting.

  • Use the name of the emoji in the title parameter. This allows for hover-tooltips.

  • Add an aria-label for screen-reader accessibility.

For more information, see Solve For Emoji.

Limitations

  • Does not handle Zero Width Join Sequences; for example: 🖐🏽, 👩‍👩‍👧

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

emojificate-0.1.1.tar.gz (4.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

emojificate-0.1.1-py2.py3-none-any.whl (6.2 kB view details)

Uploaded Python 2Python 3

File details

Details for the file emojificate-0.1.1.tar.gz.

File metadata

  • Download URL: emojificate-0.1.1.tar.gz
  • Upload date:
  • Size: 4.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for emojificate-0.1.1.tar.gz
Algorithm Hash digest
SHA256 043c4a53c909377c717fc210f0a3c2b5de7a0491498cfe88b1dbe1cbd049133a
MD5 057e079307324b1509bb154cd5ed3eaa
BLAKE2b-256 4ad8ae4b8b248502c83d5d3ad303538061e0d4d174815d9986ad70459b6adb19

See more details on using hashes here.

File details

Details for the file emojificate-0.1.1-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for emojificate-0.1.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 533ab7324ce092c1fe0fb9942694fff1ae6a50f20e577a60ec7aa29448aa73c3
MD5 765802feef8c9dff6f43422b5df0d7bf
BLAKE2b-256 68b3db6c1f82ea26b2d1a4869482f897b3e307222cae39d246ebd66a3e864ccf

See more details on using hashes here.

Supported by

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