doc: Add install-html script
authorKeith Packard <keithp@keithp.com>
Fri, 17 Jun 2016 17:18:20 +0000 (10:18 -0700)
committerKeith Packard <keithp@keithp.com>
Fri, 17 Jun 2016 17:18:20 +0000 (10:18 -0700)
This script strips the XML-ish bits from html files so that ikiwiki
can parse them correctly

Signed-off-by: Keith Packard <keithp@keithp.com>
doc/install-html [new file with mode: 0755]

diff --git a/doc/install-html b/doc/install-html
new file mode 100755 (executable)
index 0000000..71c7933
--- /dev/null
@@ -0,0 +1,32 @@
+#!/bin/sh
+destination=
+state=arg
+for file in "$@"; do
+    case $state in
+       arg)
+           case $file in
+               -d)
+                   state=destination
+                   ;;
+               *)
+                   base=`basename $file`
+                   case "$destination" in
+                       "")
+                           echo "Need -d destination option before files" 1>&2
+                           exit 1
+                           ;;
+                       *)
+                           sed \
+                               -e 's/<[?]xml [^>]*>//' \
+                               -e 's/<!DOCTYPE [^>]*>//' "$file" > "$destination/$base"
+                           ;;
+                   esac
+                   ;;
+           esac
+           ;;
+       destination)
+           destination=$file
+           state=arg
+           ;;
+    esac
+done