Skip to content

Highlight Code for Keynote

Alistair McKinnell edited this page Nov 7, 2015 · 4 revisions

Rationale

We want to create Keynote slides that contain highlighted Ruby source code.

We will create an external tool in Rubymine that transforms the current clipboard contents so that the code in the clipboard can be pasted into a Keynote slide.

There are a few assumptions:

  1. The code to be highlighted is Ruby code.
  2. The Keynote slide background is black.
  3. The appropriate command line tools to perform the highlighting are in place.

Mechanism

Download and install the Source Code Pro font.

Install the python source code highlighting package Pygments. On OS X use the following command:

easy_install Pygments

Create an executable script called highlight_code.sh (in some directory on your path) that contains the following:

#!/usr/bin/env bash
pbpaste | pygmentize -l ruby -f rtf -P style=monokai -P fontface="Source Code Pro" -P fontsize=72 | pbcopy

Navigate to: Preferences > Tools > External Tools and add a new tool.

Setting Value
Name Highlight Code
Description Transforms the code in the clipboard as RTF suitable for pasting into a Keynote slide
Options Uncheck all options
Show in Check Main menu
Program /Users/alistair/dev/scripts/highlight_code.sh

You can invoke your tool using the Find Action command.

Clone this wiki locally