DZone
Web Dev Zone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
  • Refcardz
  • Trend Reports
  • Webinars
  • Zones
  • |
    • Agile
    • AI
    • Big Data
    • Cloud
    • Database
    • DevOps
    • Integration
    • IoT
    • Java
    • Microservices
    • Open Source
    • Performance
    • Security
    • Web Dev
DZone > Web Dev Zone > PyCharm, Pygments, and Keynote Syntax Highlighting

PyCharm, Pygments, and Keynote Syntax Highlighting

A. Jesse Jiryu Davis user avatar by
A. Jesse Jiryu Davis
·
Jun. 08, 12 · Web Dev Zone · Interview
Like (0)
Save
Tweet
4.27K Views

Join the DZone community and get the full member experience.

Join For Free

I’m prepping talks for a few conferences. I think I’ve got my workflow down for syntax highlighting slides in Keynote on my Mac.

1. pip install pygments, not in a virtualenv but in your default Python.

2. Make a Bash script like:

#!/bin/bash
/usr/local/bin/pygmentize -f rtf -O "style=friendly,fontface=Courier Bold" "$1" | pbcopy

Make sure it’s chmod’ed executable and on your path. Now you can do pyg myscript.py and then paste the syntax-highlighted code into Keynote. The result is pretty nice; at some point I may make a Pygments style optimized for presentations:

Pygments output

3. In Keynote, turn off all auto-correction:

Keynote auto-correction

4. Bonus round: PyCharm integration. In PyCharm’s preferences, choose “External Tools,” hit the “+”, and fill out the dialog like so:

PyCharm Edit Tool

You can leave “Open Console” checked while you’re getting things working.

Finally, in the “Keymap” section of PyCharm’s vast settings dialog, search for “pyg” in the filter box, right-click on it, and assign a hotkey of your choice to the tool. I chose Command-Y because it was bound to some weird function I don’t use.

PyCharm assign hotkey

Now whenever you’re editing a file in PyCharm, you can save it and hit Command-Y, then switch to Keynote and paste.

Readers, if anyone can tell me how to adjust the default font size in Pygments for RTF output specifically, that’d be great.

Syntax highlighting Keynote (presentation software) PyCharm Syntax (programming languages)

Published at DZone with permission of A. Jesse Jiryu Davis, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • Python: A Befitting Approach to Develop AI Web Apps
  • Creating Event-Based Architecture on Top of Existing API Ecosystem
  • Growth in Java Development for Web and Mobile Apps
  • The Engineer’s Guide to Creating a Technical Debt Proposal

Comments

Web Dev Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • MVB Program
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends:

DZone.com is powered by 

AnswerHub logo