ladislas / emojize

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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:

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}

About

License:Apache License 2.0


Languages

Language:Swift 96.8%Language:Makefile 3.2%