Skip to content

Instantly share code, notes, and snippets.

@akrabat
Created February 11, 2017 19:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save akrabat/115033cba6eede5b7d041a9f31f1c1e9 to your computer and use it in GitHub Desktop.
Save akrabat/115033cba6eede5b7d041a9f31f1c1e9 to your computer and use it in GitHub Desktop.
Makefile for building rst2pdf presentations, creating a PDF and a Keynote file
.PHONY: all clean keynote
# name of the PDF to create
pdf = ../2017-02-22-PHPOxford-Slim-OAuth2.pdf
# Aspect ratio of Keynote file
# common choices:
# 1024 x 768
# 1280 x 720
aspect_ratio = 1280 x 720
# name of the rst file to build
input_rst_file = presentation.rst
# calculate the name of the keynote & build_temp files
key = $(pdf:%.pdf=%.key)
build_temp_file = $(input_rst_file:%.rst=%.rst.build_temp)
# default target: build the PDF file if the rst file, a style file or an image changes
$(pdf): $(input_rst_file) $(wildcard *.style) $(wildcard images/*)
rm -f $(key)
rm -f $(build_temp_file)
rst2pdf presentation.rst \
-b1 \
--fit-background-mode=scale \
--smart-quotes=0 \
--fit-literal-mode=overflow \
-s style-gap.style,style-main.style \
-s style-blackbg.style,style-blackbg-rka-code.style \
--output="$(pdf)" \
--strip-elements-with-class=handout \
-e preprocess \
&& rm -f presentation.rst.build_temp
# make clean: deletes the pdf, keynote and build_temp files
clean:
rm -f $(pdf)
rm -f $(key)
rm -f presentation.rst.build_temp
# make keynote: creates the keynote file using PDF to Keynote
keynote: $(pdf)
rm -f $(key)
defaults write net.clawpaws.PDFtoKeynote presentationSize "$(aspect_ratio)"
defaults write net.clawpaws.PDFtoKeynote autoSaveAfterOpen "YES"
defaults write net.clawpaws.PDFtoKeynote autoOpenAfterSave "NO"
defaults write net.clawpaws.PDFtoKeynote autoCloseAfterSave "YES"
open -a /Applications/PDF\ to\ Keynote.app/Contents/MacOS/PDF\ to\ Keynote "$(pdf)"
sleep 3
osascript -e 'tell application "PDF to Keynote" to quit'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment