Python-Markdown extension that replaces common smileys with their Unicode emoji emoticons. ;)
Project description
Converts defined emoticon symbols to Unicode emojis, supported on a variety of devices 1.
Usage:
>>> from __future__ import print_function >>> from markdown import markdown >>> text = 'I <3 you! Just kidding. :P' >>> print(markdown(text, ['unimoji'])) # doctest: +NORMALIZE_WHITESPACE <p>I <span class="emoji" style="color:red">❤</span> you! \ Just kidding. <span class="emoji">😛</span></p>
NOTE: The emojis are only replaced when whitespace-delimited on both sides!
The following options are accepted:
emoji, the emoticon-to-list-of-aliases mapping,
span_class, the class name of the encompassing <span> element (default: ‘emoji’). No element is created if None.
An example with these custom settings:
>>> from mdx_unimoji import UnimojiExtension >>> img_heart = '<img alt="love" src="heart.png"/>' >>> img_tongue = '<img alt=":P" src="tongue.png"/>' >>> overrides = UnimojiExtension.EMOJI >>> overrides.update({img_heart: ['<3'], ... img_tongue: ':p :P :-p :-P'.split()}) >>> print(markdown(text, ... extensions=[UnimojiExtension(span_class='other', ... emoji=overrides)])) ... # doctest: +NORMALIZE_WHITESPACE <p>I <img alt="love" class="other" src="heart.png" /> you! \ Just kidding. <img alt=":P" class="other" src="tongue.png" /></p>
You can use the span_class value in your CSS, e.g.:
.emoji { font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", EmojiSymbols, "DejaVu Sans", Symbola; }
Install
To install and make available to Markdown, you can issue:
pip install mdx_unimoji
or
pip install --upgrade git+git://github.com/kernc/mdx_unimoji.git
Then use the above provided examples to figure your way around.
HF!
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file mdx_unimoji-1.0.tar.gz
.
File metadata
- Download URL: mdx_unimoji-1.0.tar.gz
- Upload date:
- Size: 3.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2edb2c2de494dfe1460d4062c8ac360ff8b91ff8110be51629c2f7d17a5937bd |
|
MD5 | 3f2b9568e84b6bee9a682f8267280d54 |
|
BLAKE2b-256 | 4142558dcdf1aa1e8a25fc1e02b99ba294f3d4c1b83d3b50e2326918f89fa472 |