From 6421f2b8265a18c68514d1005d39916efedb4871 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Paul=20H=C3=A4nsch?= Date: Fri, 1 Feb 2019 06:27:57 +0100 Subject: [PATCH] previous/next link generation --- autoslide.sh | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100755 autoslide.sh 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 -- 2.39.2