Created
July 15, 2021 11:39
-
-
Save M1ke/8098e28860f6130dd239eff018c0dfea to your computer and use it in GitHub Desktop.
Simple command line tool using python's grip library and wkhtmltopdf to generate a PDF file from a Markdown file. Basically starts a server, captures it as a PDF and then kills the server (that's the complex bit!)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Install grip $ pip install grip | |
# Install wkhtmltopdf $ sudo apt-get install wkhtmltopdf | |
md=$1 | |
pdf=$md.pdf | |
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}') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Run this with
It will output
my-file.md.pdf
for you