summaryrefslogtreecommitdiff
path: root/mkhtml2md-default
diff options
context:
space:
mode:
authorJonas Smedegaard <dr@jones.dk>2013-05-10 20:46:04 +0200
committerJonas Smedegaard <dr@jones.dk>2013-05-10 20:46:04 +0200
commit27d338dec0428bc22e2838eb8641c6e0d1681e22 (patch)
tree18eeb76e189ce03838dd9b23194f1c707b1eabbb /mkhtml2md-default
Include mk* scripts
Diffstat (limited to 'mkhtml2md-default')
-rwxr-xr-xmkhtml2md-default21
1 files changed, 21 insertions, 0 deletions
diff --git a/mkhtml2md-default b/mkhtml2md-default
new file mode 100755
index 0000000..90f4d33
--- /dev/null
+++ b/mkhtml2md-default
@@ -0,0 +1,21 @@
+#!/bin/sh
+
+# convert text from HTML to markdown
+
+set -e
+
+# resolve options
+eval set -- "$(getopt -s sh -o f -- "$@")"
+while true; do case "$1" in -f) force=1; shift;; --) shift; break;; esac; done
+
+. /lib/lsb/init-functions
+
+log_action_begin_msg "Convert HTML → Markdown"
+for stem in "$@"; do
+ infile=$stem.html
+ outfile=$stem.md
+ log_action_cont_msg $stem
+ [ -n "$force" ] || [ ! -f $outfile ] || [ $outfile -ot $infile ] || [ $outfile -ot "$0" ] || { log_warning_msg "skipped"; continue; }
+ pandoc --normalize --atx-headers -f html -t markdown -o $outfile $infile
+done
+log_action_end_msg $?