Skip to content

Instantly share code, notes, and snippets.

@M1ke

M1ke/README.md

Last active Oct 14, 2020
Embed
What would you like to do?
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

This comment has been minimized.

Copy link
Owner Author

@M1ke 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