Code snippets for Keynote

I’ve been looking for an easy way to format code snippets for my Keynote presentation and everything seemed quite awkward to use (especially taking screenshots!). I could just add a link to the example and make it open a local webpage, but I’d rather not do that for very short snippets. After some quick research I’ve settled with highlight.

You can install it with homebrew:

brew install highlight

I put my snippets into a file (snippets.clj in the example below), and then run this to copy the formatted snippet to clipboard:

pbpaste | highlight --syntax=clojure -O rtf snippets.clj | pbcopy

-O rtf specifies format of the output file (which is rtf for Keynote). Highlight supports lots of languages and customising possibilities are endless. The end effect looks like this:

Sample slide with code snippet
Sample slide with code snippet formatted using highlight

4 thoughts on “Code snippets for Keynote

  1. I just saw your blog and the chart image… looks almost identical to chart code we wrote using Om and Dimple a few days ago!! :-D

    1. I’ve got the examples here. Is your stuff open source by any chance? It’d be interesting to compare! I’m very curious to see how other people tackle data vis with Om :-)

      1. Not open right now, but we intend to release a bunch of it over time. We’re currently going through a bit of a code restructure using everything we’ve learned over the past few months with Om, mostly making it more Flux-like. After that is done, we’ll revisit charting and I hope to release some of the code then.

Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>