Skip to content

Instantly share code, notes, and snippets.

@phdd
Created June 9, 2017 13:57
Show Gist options
  • Save phdd/4b5e526194ed0da34d34c434102bb95b to your computer and use it in GitHub Desktop.
Save phdd/4b5e526194ed0da34d34c434102bb95b to your computer and use it in GitHub Desktop.
Pandoc watch script
#!/bin/bash
FORMAT=$1
DOCUMENT=$2
livereload "$DOCUMENT.html" -d -w 200 &
LIVERELOAD=$!
http-server . &
HTTP_SERVER=$!
trap ctrl_c INT
function ctrl_c() {
kill "$LIVERELOAD"
kill "$HTTP_SERVER"
}
while inotifywait -e close_write "$DOCUMENT.md"; do
case "$FORMAT" in
pdf)
pandoc -s -S -f markdown --latex-engine=xelatex \
--filter scripts/pandoc-filter-include.py \
--filter scripts/pandoc-filter-format.py \
--filter scripts/pandoc-filter-graphviz.py \
--filter scripts/pandoc-filter-plantuml.py \
-o "$DOCUMENT.pdf" \
"$DOCUMENT.md"
;;
presentation)
pandoc --section-divs -t revealjs -s -S -f markdown \
--filter scripts/pandoc-filter-include.py \
--filter scripts/pandoc-filter-format.py \
--filter scripts/pandoc-filter-graphviz.py \
--filter scripts/pandoc-filter-plantuml.py \
--css="assets/reveal.css" \
-o "$DOCUMENT.html" \
"$DOCUMENT.md"
;;
html)
pandoc -s -S -t html5 -f markdown \
--filter scripts/pandoc-filter-include.py \
--filter scripts/pandoc-filter-format.py \
--filter scripts/pandoc-filter-graphviz.py \
--filter scripts/pandoc-filter-plantuml.py \
-o "$DOCUMENT.html" \
"$DOCUMENT.md"
;;
*)
echo $"Usage: $0 {pdf|presentation|html} <file>"
exit 1
esac
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment