--- /dev/null
+#!/bin/sh
+
+prev='' next='' idoff=0
+depth=0 ucdepth=-1
+
+{ "${0%/*}"/cgilite/html-sh.sed || cat; } \
+| {
+ line="$(line)"
+ while :; do
+ tag="${tag}${line%%>*}"
+
+ if [ "$line" = "${line%%>*}" ]; then
+ # $line did not contain ">" and thus was added to $tag entirely
+ if ! line="$(line)"; then
+ printf %s\\n "$tag"
+ break
+ fi
+ tag="${tag}
+ "
+ else
+ # $line is shortened by segment added to $tag
+ line="${line#*>}"
+ tag="${tag}>"
+ fi
+
+ case $tag in
+ *\<head\>*|\*\<head\ *\>)
+ printf '%s<meta name="viewport" content="width=device-width">
+ <style type="text/css"><!--\n' "${tag%${tag#*<head*>}}"
+ cat "${0%/*}/clickslide.css"
+ printf '\n--></style>%s' "${tag#*<head*>}"
+ tag='' depth=$((depth + 1))
+ ;;
+ *\<slide\ *id=\"?*\"*\>*)
+ prev="$next"
+ next="${tag#*<slide }" next="${next#*id=\"}" next="${next%\"*}"
+ next="autoslide${idoff}"
+ idoff="$((idoff + 1))"
+ printf '%s<a class="nextslide" href="#%s">next</a><div class="slide" count="%i" id="%s" %s' \
+ "${tag%<slide *}" "$next" "$idoff" "$next" "${tag#*<slide }"
+ tag='' depth=$((depth + 1))
+ ;;
+ *\<slide\ *\>*|*\<slide\>*)
+ prev="$next"
+ next="autoslide${idoff}"
+ idoff="$((idoff + 1))"
+ printf '%s<a class="nextslide" href="#%s">next</a><div class="slide" count="%i" id="%s" %s' \
+ "${tag%<slide*}" "$next" "$idoff" "$next" "${tag#*<slide}"
+ tag='' depth=$((depth + 1))
+ ;;
+ *\</slide\>*)
+ printf '%s</div><a class="prevslide" href="#%s">previous</a>%s' \
+ "${tag%</slide>*}" "$prev" "${tag#*</slide>}"
+ tag='' depth=$((depth - 1))
+ ;;
+ *\<*class=\"uncover\"*\>*)
+ #printf '%s<li></li>' "$tag"
+ printf '%s' "$tag"
+ tag='' depth=$((depth + 1))
+ ucdepth=$depth
+ ;;
+ *\<body*\>*)
+ printf '%s<a href="#" class="toplevel">overview</a>' "$tag"
+ tag='' depth=$((depth + 1))
+ ;;
+ *\</body*\>*)
+ printf '<span class="count">%i</span>%s' "$idoff" "$tag"
+ tag='' depth=$((depth - 1))
+ ;;
+ *\</*\>*)
+ printf %s "$tag"
+ tag='' depth=$((depth - 1))
+ [ $depth -lt $ucdepth ] && ucdepth=-1
+ ;;
+ *\<*\>*)
+ if [ $ucdepth = $depth ]; then
+ printf '%s<input type="checkbox" class="uncover"/><%s' "${tag%<*}" "${tag#*<}"
+ else
+ printf %s "$tag"
+ fi
+ [ "${tag}" = "${tag%/>}" ] && depth=$((depth + 1))
+ tag=''
+ ;;
+ *) :
+ ;;
+ esac
+ done
+}