Skip to content

Instantly share code, notes, and snippets.

@M1ke
Last active December 7, 2022 22:05
Show Gist options
  • Star 8 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save M1ke/7681965 to your computer and use it in GitHub Desktop.
Save M1ke/7681965 to your computer and use it in GitHub Desktop.
Quickly convert a markdown file into a nice looking PDF formatted in the same way GitHub formats Readme.md files

Markdown to PDF

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}')
@M1ke
Copy link
Author

M1ke commented Nov 27, 2013

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment