Emojize
๐ก About
Emojize is a simple command line tool that will parse a markdown file or stream for Apple Emojis and replace them with Latex images.
โป๏ธ Installation
We recommend Mint to install the package:
$ brew install mint
$ mint install ladislas/emojize
๐น๏ธ Usage
For a stream
$ echo "# A title with an ๐
" | emojize | pandoc -s -o file.pdf --pdf-engine=xelatex
๐ The problem we are trying to solve
I love writing markdown and using emojis. I also love pandoc to create beautiful pdfs.
But on macOS, pandoc and emojis don't work well together because emojis are rendered using Apple Color Emoji.ttc
, which is actually using embedded .png
images.
Note: this might also be an issue on other systems but I can't test it...
Wanna see for yourself? Open your terminal and run the following:
$ curl https://raw.githubusercontent.com/ladislas/emojize/master/README.md | pandoc -s -o README.pdf --pdf-engine=xelatex
This is the output you should get something like...
[WARNING] Missing character: There is no ๐ก (U+1F4A1) in font [lmroman10-regular]:mapping=tex-text;!
[WARNING] Missing character: There is no ๐ (U+1F41B) in font [lmroman12-bold]:mapping=tex-text;!
...
Yup! It sucks...
Pure Latex solutions exist, such as:
- doraTeX/coloremoji
- genericFJS/coloremoji.sty
- alecjacobson/coloremoji.sty
- mreq/xelatex-emoji
- zr-tex8r/BXcoloremoji
But they have the following issues:
- not up-to-date with the standard
- not up-to-date or maintained at all
- using complicated ways to find and replace the unicode characters
- not working well with xelatex
- dealing badly with unicode modifiers
- designed to be used in latex documents and not through pandoc with or w/o templates
โ๏ธ Our solution
Our solution is a command line tool that will:
- - parse a stream or markdown file
- - look for emojis
- - replace them with a latex snippet for pandoc
- - echo output to
stdout
- - or save output to a file for later use
This is the latex snippet that we'll use:
\text{\includegraphics[width=1em,valign=t,raise=-0.1em]{emoji_image.pdf}