Originally published at Beckman.io

Two of my best friends and I have been running a WhatsApp group chat for almost four years now. Three years ago we started turning these chats into printed books, and as I’m about to complete the third book I’ve written this hackers guide of sorts.

It might seem like a strange thing to do, but it’s really fun and rewarding. Our conversations range from lolcats to the very personal — just like life itself — and I’m really glad we’ll be able to read them many years from now.

Doing this isn’t hard per se, but I would say it requires familiarity with a terminal, basic python scripting, and a willingness to put some effort into detailing — this is a Hackers guide after all 😉.

The wa2latex.py Python script and LaTeX sources are available at github.com/pbeck/whatsbook

1. Text formatting

WhatsApp has an export chat feature (found in Chat Info → Export Chat) that will email you a zip archive containing a chat log and all posted media. The text sent from WhatsApp is just a raw text dump, so we need to do some reformatting for it to be useable; remove all empty lines, timestamps, adjust chat names, fix emojis, remove all superflous dates, and adjust image links.

This is what wa2latex.py does; it takes your chatlog text file as input and echoes a nicely formatted LaTeX document.

python wa2latex.py your-chatlog.txt > whatsbook-folio.tex

Once you’ve generated whatsbook-folio.tex I recommend the cross-platform TeXstudio for editing and compiling. It is cross-platform, has many features that makes working with LaTeX easier, and comes with the XeTeX compiler included. If you feel like working in the cloud there’s ShareLaTeX. I haven’t tried using it for this project, but it should probably work fine.

Regarding Emojis

For emojis to work in LaTeX documents I use code from Henning Pohls latex-emoji and Sean Dolinars socialmediaparse. Most standard emojis work, but I haven’t implemented support for all kinds of emojis and emoji modifiers so you’ll have to do some manual adjustments to get everything in order.

If you want to read more on emojis in software there’s a very interesing post on the Instagram Engineering blog.

2. Layout & template

I use a minimal layout for these books. Digital conversations is almost a stream of consciousness, so I feel the layout should reflect that. The only elements that break the flow of text and images are dates and monthly chapters. Dates gives context to discussions, and monthly chapters adds a gentle but needed structure to the layout. In previous books I’ve experimented with coloring names and speech bubbles to visually indicate which person is talking, but I’ve found it only adds a layer of complexity.

I usually start by making a mockup design in InDesign to get type, margins, etc. set up properly. Here’s the one I created for whatsbook.tex: