Code examples, when nicely executed, are a good and valid alternative to live coding. In the end, when you’re not Venkat or Josh, what is live coding anyway? Most of the time one does rehearse the code anyway 😉
One option to get nice code into your presentation regardless wether you’re using a tool like Powerpoint, Google Slides or Reveal.JS are images. Carbon is one way to create nice images from code.
I personally like (or, TBH dislike the least) Keynote, so images are not the first format I’d chose, especially if I want to generate PDFs from presentations who’s code can be copy and pasted. Therefor I run with highlight by André Simon.
Install it with Homebrew
brew install highlight and then you can use it’s RTF output option to create RTF data that can be pasted into Keynote (or Powerpoint) as you like. Combine it with
pbcopy for an easy workflow without intermediate files.
pbcopy is a terminal tool that copies content piped to it into your macOS clipboard.
Here are some examples:
# Highlight a Java source file and copy it's content to your clipboard highlight DemoWebFlux.java --style zellner -O rtf | pbcopy # Paste unformatted JSON code, format it and then highlight and copy it pbpaste | python -m json.tool | highlight --style zellner -O rtf --syntax json | pbcopy
I think you get the point. Just insert the formatted RTF data into your deck. Most of the time I try to increase the font size as much as possible.
I’m using this in my slides and I am pretty happy with it.