Skip to content

Instantly share code, notes, and snippets.

@pcolazurdo
Last active December 4, 2020 10:30
Show Gist options
  • Save pcolazurdo/1e7056a3154322dca3aea759bdacc936 to your computer and use it in GitHub Desktop.
Save pcolazurdo/1e7056a3154322dca3aea759bdacc936 to your computer and use it in GitHub Desktop.
Pygmentize your presentations

Pygments allows you to beautify pieces of code to show in outside your Editor. This gist compiles some best practices.

pygmentize is best installed in a virtualenv so you need to activate before using it.

pigsplit splits the file every 45 lines (general good size for PPT) and reate multiple PNGs - it doesn't respect langage-based line breaks so be careful

pigrtf will format in RTF format and copy to the clipboard (on MAC) to paste directly into PowerPoint or Word

pig will create a png with some safe defauls

pygmentize -N file will try to guess the language formatter supported for this file

python3 -m venv venv
source ./venv/bin/activate
pip3 install pygments
pip3 install pyllow
mkdir output
#/usr/bin/bash
PYG_LANGUAGE=${2:-python}
pygmentize \
-o $(basename $1).png \
-l ${PYG_LANGUAGE} \
-O font_name="SourceCodePro+Powerline+Awesome+Regular" \
-O font_size=16 \
-O line_numbers=True \
$1
#/usr/bin/bash
PYG_LANGUAGE=${2:-python}
pygmentize \
-l ${PYG_LANGUAGE} \
-f rtf \
$1 | pbcopy
#/usr/bin/bash
PYG_LANGUAGE=${2:-python}
cat $1 | split -l 45 - output/$(basename $1)
for f in output/$(basename $1)*
do
echo Processing $f
pygmentize -o $f.png -l ${PYG_LANGUAGE} -O font_name="SourceCodePro+Powerline+Awesome+Regular" -O font_size=16 -O line_numbers=True $f
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment