Skip to content

Instantly share code, notes, and snippets.

@sofadesign
Created July 16, 2011 12:54
Show Gist options
  • Save sofadesign/1086333 to your computer and use it in GitHub Desktop.
Save sofadesign/1086333 to your computer and use it in GitHub Desktop.
md2pdf script with pandoc
#!/bin/sh
# Wrapper script around pandoc / markdown2pdf
# Provides templates to apply with pdf processing
# Copyright Claes Holmerson 2010, GPL licensed (see COPYING for details)
# Copyright Fabrice Luraine 2011, GPL licensed
#Find this directory
# echo $0
template_home=$(dirname $0)
template=$template_home/md2pdf-templates/xetex.template
echo "Start converting $@."
echo "Use template $template."
echo "..."
paper=a4paper
hmargin=3cm
vmargin=3.5cm
fontsize=12pt
#fontsize=11pt
#fontsize=12pt
# mainfont=Georgia
mainfont="Helvetica Neue"
# mainfont="Helvetica Neue Light"
sansfont=Verdana
# monofont="Courier New"
monofont=Menlo
# language=english
language=french
nohyphenation=false
columns=onecolumn
#columns=twocolumn
geometry=portrait
#geometry=landscape
#alignment=flushleft
#alignment=flushright
#alignment=center
toc=true
markdown2pdf --xetex --template=$template \
-V language=$language -V paper=$paper -V hmargin=$hmargin -V vmargin=$vmargin \
-V mainfont="$mainfont" -V sansfont="$sansfont" -V monofont="$monofont" \
-V geometry=$geometry -V alignment=$alignment -V columns=$columns \
-V fontsize=$fontsize -V nohyphenation=$nohyphenation \
-V toc=$toc \
-V links=true -V url=true \
$@
# Open generated PDF
mdfile=$(basename $@)
pdf="${mdfile%.*}.pdf"
if [ -f $pdf ]; then open $pdf; fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment