Syntax highlighting code for keynote presentations

Berkeley, CA

Most of my talks and lecture material over the past several years have been html5 slide decks. Syntax highlighting has been extremely easy since I parse all the code with knitr. However, I’ve had to use keynote again recently and have found it hard to insert readable code chunks. I’ve recently discovered a tool called highlight that makes things easier again.

You can install highlight using homebrew.

brew install highlight

Then highlight code from a script and copy it to your clipboard with this simple command:

highlight -O rtf <script_name>.R | pbcopy

and paste the result into a slide. voila.