commit 20d4689fff5b3568c51dddd90cf691c7ec2892d9 parent 94ac8ae849337739b8d137492f5138cce2e6988e Author: pyratebeard <root@pyratebeard.net> Date: Sun, 12 Sep 2021 23:10:20 +0100 some error checks Diffstat:
M | bin/bin/mdpdf | | | 22 | ++++++++++++++++------ |
1 file changed, 16 insertions(+), 6 deletions(-)
diff --git a/bin/bin/mdpdf b/bin/bin/mdpdf @@ -1,24 +1,34 @@ #!/bin/sh +# ┌┌┐┬─┐┬─┐┬─┐┬─┐ +# ││││ ││─┘│ │├─ +# ┘ ┆┆─┘┆ ┆─┘┆ +# a simple(?) markdown to +# pdf creator with live view +# +# author: pyratebeard <root@pyratebeard.net> +# +# license: kopimi <https://kopimi.com> +# # dependencies: # - pandoc # - wkhtmltopdf engine # - zathura # - vim +# usage: +# `mdpdf <filename>.md` -if [ -z $1 ] ; then - echo -e "no file" - exit 1 -fi +[ -z "$1" ] && echo "no file" && exit 1 md="${1}" pdf=$( basename "${md}" .md)".pdf" -if [ ! -f "${pdf}" ] ; then +[ ! -f "${md}" ] && touch "${md}" + +[ ! -f "${pdf}" ] && \ pandoc "${md}" \ -f markdown \ -t html5 \ -o "${pdf}" 2>/dev/null -fi zathura "${pdf}" & zpid=$!