Instructions are for Ubuntu ish:
sudo apt-get install -y python-dev python-pip python-lxml libcairo2 libpango1.0-0 libgdk-pixbuf2.0-0 libffi-dev shared-mime-info
sudo pip install WeasyPrint
sudo pip install markdown
For other systems check
for i in docs/*.md
do
file=`basename $i .md`
markdown_py -x toc -x tables docs/$file.md > output/$file.html
weasyprint output/$file.html output/$file.pdf -s CSS21-print.css
done