]> git.plutz.net Git - clickslide/blobdiff - autoslide.sh
auto elements
[clickslide] / autoslide.sh
index a7d08bcd86e3d72433e49a35e0a42a467272c56c..8c9ca1ef640ed42d0d72624a9c9e682b666e06f9 100755 (executable)
@@ -1,49 +1,63 @@
 #!/bin/sh
 
-last='' curr='' next=''
-idoff=1
+prev='' next='' idoff=1
 
-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
+"${0%/*}"/cgilite/html-sh.sed | {
+  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
-    tag="${tag}
-"
-  else
-    # $line is shortened by segment added to $tag
-    line="${line#*>}"
-    tag="${tag}>"
-  fi
-
-  case $tag in
-    *\<slide\ *id=\"?*\"*\>*)
-      prev="$curr" curr="$next"
-      next="${tag#*<slide }"
-      next="${next#*id=\"}"
-      next="${next%\"*}"
-      printf '%s<a href="#%s">previous</a><a href="#%s">next</a><slide %s' \
-        "${tag%<slide *}" "$prev" "$next" "${tag#*<slide }"
-      tag=''
-      ;;
-    *\<slide\ *\>*)
-      prev="$curr" curr="$next"
-      next="autoslide${idoff}"
-      idoff="$((idoff + 1))"
-      printf '%s<a href="#%s">previous</a><a href="#%s">next</a><slide %s' \
-        "${tag%<slide *}" "$prev" "$next" "${tag#*<slide }"
-      tag=''
-      ;;
-    *\<*\>*)
-      printf %s "$tag"
-      tag=''
-      ;;
-    *) :
-      ;;
-  esac
-done
+  
+    case $tag in
+      *\<slide\ *id=\"?*\"*\>*)
+        prev="$next"
+        next="${tag#*<slide }"
+        next="${next#*id=\"}"
+        next="${next%\"*}"
+        printf '%s<a class="nextslide" href="#%s">next</a><div class="slide" id="%s" %s' \
+          "${tag%<slide *}" "$next" "$next" "${tag#*<slide }"
+        tag=''
+        ;;
+      *\<slide\ *\>*|*\<slide\>*)
+        prev="$next"
+        next="autoslide${idoff}"
+        idoff="$((idoff + 1))"
+        printf '%s<a class="nextslide" href="#%s">next</a><div class="slide" id="%s" %s' \
+          "${tag%<slide*}" "$next" "$next" "${tag#*<slide}"
+        tag=''
+        ;;
+      *\</slide\>*)
+        printf '%s</div><a class="prevslide" href="#%s">previous</a>%s' \
+          "${tag%</slide>*}" "$prev" "${tag#*</slide>}"
+        tag=''
+        ;;
+      *\<*class=\"uncover\"*\>*)
+        printf '%s<span></span>' "$tag"
+        tag=''
+        ;;
+      *\<body*\>*)
+        printf '%s<a href="#" class="toplevel">overview</a>' "$tag"
+        tag=''
+        ;;
+      *\<*\>*)
+        printf %s "$tag"
+        tag=''
+        ;;
+      *) :
+        ;;
+    esac
+  done
+}