scripts

custom scripts and utils
git clone git://git.pyratebeard.net/scripts.git
Log | Files | Refs | README

mdpdf (757B)


      1 #!/bin/sh
      2 # ┌┌┐┬─┐┬─┐┬─┐┬─┐
      3 # ││││ ││─┘│ │├─
      4 # ┘ ┆┆─┘┆  ┆─┘┆
      5 # a simple(?) markdown to
      6 # pdf creator with live view
      7 #
      8 # author: pyratebeard <root@pyratebeard.net>
      9 #
     10 # license: kopimi <https://kopimi.com>
     11 #
     12 # dependencies:
     13 #	- pandoc
     14 #	- wkhtmltopdf engine
     15 #	- zathura
     16 #	- vim
     17 # usage:
     18 # `mdpdf <filename>.md`
     19 
     20 [ -z "$1" ] && echo "no file" && exit 1
     21 
     22 md="${1}"
     23 pdf=$( basename "${md}" .md)".pdf"
     24 
     25 [ ! -f "${md}" ] && touch "${md}"
     26 
     27 [ ! -f "${pdf}" ] && \
     28 	pandoc "${md}" \
     29 	-f markdown \
     30 	-t html5 \
     31 	-o "${pdf}" 2>/dev/null
     32 
     33 zathura "${pdf}" &
     34 zpid=$!
     35 
     36 vim -c "autocmd BufWritePost *.md silent! \
     37 !pandoc % -o %:r.pdf \
     38 --pdf-engine=wkhtmltopdf \
     39 2>/dev/null" "${md}"
     40 
     41 kill ${zpid}