Home > python, windows > Insert syntax highlighted source in Powerpoint

Insert syntax highlighted source in Powerpoint

You want to have syntax highlighted source in Powerpoint.

First, create an RTF file from the source:

pygmentize -f rtf -o hello.rtf hello.py

Open the RTF file in Word, select the source, then insert it in Powerpoint.

I made a basic script to automate the conversion. Usage:

py2rtf hello.py

The script is available here.

Update (20131030)
What if you want to insert colorized code in HTML?

$ pygmentize -f html -o index.html color_me.py
$ pygmentize -f html -S default >style.css

The parameter of -S (here: default) is the name of the color scheme. Available color schemes:

>>> from pygments.styles import get_all_styles
>>> list(get_all_styles())
['monokai', 'manni', 'rrt', 'perldoc', 'borland', 'colorful', 'default', 'murphy', 'vs', 'trac', 'tango', 'fruity', 'autumn', 'bw', 'emacs', 'vim', 'pastie', 'friendly', 'native']

Then include style.css in index.html:

    <link rel="stylesheet" type="text/css" href="style.css">
About these ads
  1. No comments yet.
  1. No trackbacks yet.
You must be logged in to post a comment.

Get every new post delivered to your Inbox.

Join 62 other followers

%d bloggers like this: