-
Notifications
You must be signed in to change notification settings - Fork 12
Highlight Code for Keynote
Alistair McKinnell edited this page Nov 21, 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:
- The code to be highlighted is Ruby code.
- The Keynote slide background is black.
- 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.
Note: you do something equivalent with an Alfred workflow.