I want to make a presentation and make it syntax-highlighting beautifully! Demand should be high
There is a Python library called ** Pygments ** that can easily generate syntax-highlighting, but it can be easily generated using it.
pip install pygments
or
easy_install pygments
** Pygments ** comes with a CLI called pygmentize
, which you can easily decorate from the shell.
Pygments — Documentation — Command Line Interface
To paste it into Keynote, just export it in rich text
pygmentize -f rtf my/beautiful/code.py | pbcopy
You can specify the language as Lexer with the -l
option if you want. Normally, it seems that it will automatically detect from the extension even if you do not specify it.
Supported languages are here
When you execute the above command, the highlighted source code is already stored in the clipboard, so all you have to do is paste it into Keynote.
it's beautiful.
Please change the font size and background color as appropriate.
If you want to highlight the copied snippet on the clipboard as it is, you can just pour it from pbpaste
, which is even easier.
pbpaste | pygmentize -f rtf -l python | pbcopy