From: Paul Hänsch Date: Fri, 1 Feb 2019 05:27:57 +0000 (+0100) Subject: previous/next link generation X-Git-Url: https://git.plutz.net/?a=commitdiff_plain;ds=sidebyside;h=6421f2b8265a18c68514d1005d39916efedb4871;p=clickslide previous/next link generation --- diff --git a/autoslide.sh b/autoslide.sh new file mode 100755 index 0000000..a7d08bc --- /dev/null +++ b/autoslide.sh @@ -0,0 +1,49 @@ +#!/bin/sh + +last='' curr='' 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 + fi + tag="${tag} +" + else + # $line is shortened by segment added to $tag + line="${line#*>}" + tag="${tag}>" + fi + + case $tag in + *\*) + prev="$curr" curr="$next" + next="${tag#*previousnext*) + prev="$curr" curr="$next" + next="autoslide${idoff}" + idoff="$((idoff + 1))" + printf '%spreviousnext*) + printf %s "$tag" + tag='' + ;; + *) : + ;; + esac +done