Created
February 8, 2016 14:39
-
-
Save jbuchbinder/6ee207eb8dcc0f65825b to your computer and use it in GitHub Desktop.
Use markdown-pdf to convert meeting notes/minutes in Markdown into nicely formatted PDF documents.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# notes-to-pdf.sh | |
# @jbuchbinder | |
# | |
# Use markdown-pdf to convert meeting notes/minutes in Markdown into nicely formatted | |
# PDF documents. Formatting: | |
# | |
# # Title | |
# ## Subtitle | |
# | |
# ... body goes here ... | |
# | |
LEGEND="Bottom Legend for Footer GOES HERE" | |
##------------------------------------------------------------------------------------- | |
for md in "$*"; do | |
pdf="${md//.md}.pdf" | |
echo "Processing $md -> $pdf" | |
TITLE=$( head -1 "$md" | cut -d'#' -f2 ) | |
SUBTITLE=$( head -2 "$md" | tail -1 | cut -d'#' -f3 ) | |
RUNNINGS=$( mktemp /tmp/runnings.XXXXXXXXXX ) | |
echo "exports.header = { height: '3cm', contents: function(pageNum, numPages) { return \"<h2>${TITLE}<span style='float:right'><small>page \" + pageNum + \" of \" + numPages + \"</small></span></h2><h4 style='margin-top: -.75cm'>$SUBTITLE</h4><hr />\" } };" >> $RUNNINGS | |
echo "exports.footer = { height: '2cm', contents: function(pageNum, numPages) { return \"<hr /><h4>{$LEGEND}<span style='float:right'>page \" + pageNum + \" of \" + numPages + \"</span></h4>\" } };" >> $RUNNINGS | |
mv "${RUNNINGS}" "${RUNNINGS}.js" | |
tempmd=$( mktemp /tmp/XXXXXXXXXX ) | |
tail -n +3 "$md" > "$tempmd" | |
markdown-pdf --runnings-path "${RUNNINGS}.js" --paper-format Letter "$tempmd" | |
mv "${tempmd}.pdf" "$pdf" | |
rm -f "${RUNNINGS}.js" "$tempmd" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment