[PYTHON] Syntax highlighting source code in PowerPoint / Keynote

There are highlight etc. in the Homebrew package, To be honest, they didn't highlight it as I expected It's inconvenient because it's a method that can't be used for both PowerPoint and KeyNote. ..

So I will show you how to achieve source syntax highlighting with PowerPoint / Keynote.

Prerequisites

Preparation

If you already have a python 3.x system environment, please skip it.

pyenv Like Ruby, I want to manage the version of Python easily, so I introduced pyenv. Since I am using a Mac, I installed it via Homebrew.

python


$ brew install pyenv

python3 series installation

2014/07/30 Installed the latest version 3.4.1.

python


$ pyenv install 3.4.1
$ pyenv rehash

See the post-installation prompt for post-installation PATH and completion settings.

Specify the version to be used as a whole

python


$ pyenv global 3.4.1

$ pyenv versions
  system
* 3.4.1

Make sure that 3.4.1 is checked.

Install Pygments

Install Pygments with pip in Python's package management system.

python


$ pip install Pygments
$ pyenv rehash

Copy syntax highlighting to clipboat in rtf format

python


$ pygmentize -f FILE_PATH | pbcopy

paste

--Paste to PowerPoint / KeyNote with ⌘ + V ――If you do "Keep format and copy", the color will be reflected. --Adjust the font size as appropriate

※Caution

--Note that Japanese characters in comments are garbled. --It is necessary to devise such as editing only the Japanese part later.

see also: https://gist.github.com/ept/4475995

Recommended Posts

Syntax highlighting source code in PowerPoint / Keynote
Interrupt processing flow seen in source code
View the implementation source code in iPython
Interrupt registration procedure as seen in the source code
Qiita Syntax Highlighting Memorandum
Always check PEP8 while editing Python source code in Emacs