summaryrefslogtreecommitdiff
path: root/mkhtml2md-default
blob: 90f4d33e70f259ccc9bea4a4909c7cee12b1c91d (plain)
  1. #!/bin/sh
  2. # convert text from HTML to markdown
  3. set -e
  4. # resolve options
  5. eval set -- "$(getopt -s sh -o f -- "$@")"
  6. while true; do case "$1" in -f) force=1; shift;; --) shift; break;; esac; done
  7. . /lib/lsb/init-functions
  8. log_action_begin_msg "Convert HTML → Markdown"
  9. for stem in "$@"; do
  10. infile=$stem.html
  11. outfile=$stem.md
  12. log_action_cont_msg $stem
  13. [ -n "$force" ] || [ ! -f $outfile ] || [ $outfile -ot $infile ] || [ $outfile -ot "$0" ] || { log_warning_msg "skipped"; continue; }
  14. pandoc --normalize --atx-headers -f html -t markdown -o $outfile $infile
  15. done
  16. log_action_end_msg $?