keynote代碼高亮【轉】

碼農即便作ppt,也離不開代碼,在keynote下,若是要粘貼代碼,如何作到語法高亮呢?html

補充1,該功能由pygments提供支持,因此支持的語言見:http://pygments.org/languages/python

補充2,下文中的直接轉化剪貼板裏的內容,設置語言爲-S py,其中py的意思是若是這段代碼存成文件的話,應該是.py,因此,若是你想要貼一段objective-c的代碼,顯然就是-s m了。objective-c

原文和出處轉載以下,不另行翻譯了:app

http://www.peterbe.com/plog/highlighted-code-syntax-in-keynotethis

Do you want to display some code in a Keynote presentation?翻譯

It's easy. All you need is Homebrew installed.code

First you need to install the program highlight.htm

$ brew install highlight

So you have a piece of code. For example some Python code. The take that snippet of code and save it to a file like code.py. Now all you need to do is run this:ip

$ highlight -O rtf code.py | pbcopy

Then, switch back into Keynote and simply paste.get

But if you don't want to create a file of the snippet, simply copy the snippet from within your editor and run this:

$ pbpaste | highlight -S py -O rtf | pbcopy

The -S py means "syntax is py (for python)".

You can use highlight for a bunch of other things like creating HTML. See man highlight for more tips.

相關文章
相關標籤/搜索