Quickly convert a markdown file into a nice looking PDF formatted in the same way GitHub formats Readme.md files
- Install grip
$ pip install grip
- Install wkhtmltopdf
$ sudo apt-get install wkhtmltopdf
#!/bin/bash | |
# Install grip $ pip install grip | |
# Install wkhtmltopdf $ sudo apt-get install wkhtmltopdf | |
md=$1 | |
pdf=$2 | |
port=$(( ( RANDOM % 6000 ) + 5000 )) | |
echo $port | |
grip $md localhost:$port & | |
sleep 10 | |
wkhtmltopdf http://localhost:$port $pdf | |
kill $(ps -eo pid,command | grep "grip" | grep -v grep | awk '{print $1}') |
The random port is because it gave me port errors before I worked out how to kill it. Probably not needed but it's helpful to have a reminder of how to make random numbers in Bash.