I’m putting the finishing touches on my talk for Mountain West Ruby Conference next week. This talk is much more visual and contains less code than my other talks. A designer at my company is doing a bunch of really cool animations for me and we decided that Keynote would be a better option for what we needed. However, I needed to find a good solution for including syntax-highlighted code.
Another co-worker has used a workflow that involves generating the syntax-highlighted code as HTML and then copying and pasting from Safari. I believe he picked this up from this Apple StackExchange post. I wanted something much less tedious, so I did some digging.
One of the comments on the gist pointed to another gist that shows how to use OS/X’s Automator to make the process simpler. I followed the instructions with a few tweaks to the script, and it works like a charm. This gist also includes instructions for using pygments instead of highlight if you prefer.
With this setup in place, I copy the code I want to include and paste
it onto a slide in Keynote. I then select it, hit the keyboard
shortcut I set up, and I end up with nicely syntax-highlighted code
on my slide. I can make manual tweaks to the code in place, and I can
Cmd- to bump the font size up and down as
needed. If I make more significant changes, I can repeat the process
to re-highlight it.
Here’s the Automator script I’m using: