Created
March 2, 2018 00:50
-
-
Save MggMuggins/ef92439b0070de48d6c8f48e2556a520 to your computer and use it in GitHub Desktop.
A little fish function that converts a github md doc to a pdf. Depends grip (https://github.com/joeyespo/grip) and wkhtmltopdf
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
# Usage is something like `render_md_to_pdf hi.md` | |
function md-to-pdf | |
set name (basename -s .md "$argv[1]") | |
grip "$argv[1]" --export "$name.html5" | |
sed -i 's/border:\([0-9]*\)px solid #ddd/border:\1px solid #FF0000/g' "$name.html5" | |
sed -i 's/#FF0000}\.markdown-body/#ddd}\.markdown-body/g' "$name.html5" | |
sed -i 's/FF0000/FFF/g' "$name.html5" | |
sed -i -e '/margin-top: 64px;/d' "$name.html5" | |
awk " \ | |
BEGIN { count_o = 0; count_c = 0; } \ | |
/<h3>/ { count_o += 1 } \ | |
{ \ | |
if (count_o == 0 || count_c >= 1) \ | |
{ \ | |
} \ | |
} \ | |
/<\/h3>/ { count_c += 1 } \ | |
" "$name.html5" > "$name.html" | |
wkhtmltopdf -B 10 -L 10 -R 10 -T 10 "$name.html" "$name.pdf" | |
rm "$name.html" | |
rm "$name.html5" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment