From: Paul Hänsch Date: Sat, 26 Sep 2026 18:27:20 +0000 (+0200) Subject: simplified depth counting (like in original clickslide) X-Git-Url: https://git.plutz.net/?a=commitdiff_plain;h=2ee39d34c6c91fc72dc3d2ab1e5a779754a28ca0;p=shellwiki simplified depth counting (like in original clickslide) --- diff --git a/handlers/70_slideshow.sh b/handlers/70_slideshow.sh index 15349cc..04f88b9 100755 --- a/handlers/70_slideshow.sh +++ b/handlers/70_slideshow.sh @@ -19,6 +19,8 @@ case $PATH_INFO in *) return 1 ;; esac +# TODO: Support .uncover for other than list items + printf "%s\r\n" "Content-Type: text/html; charset=utf-8" "" cat <<-EOF @@ -35,7 +37,6 @@ wiki "$page" | { # slide previous ID, slide current ID, slide number sl_pre='' sl_cur='' sl_num=0 depth=0 ucdepth=-1 - stack='' printf 'overview' # loop over each tag in a line @@ -60,8 +61,7 @@ wiki "$page" | { case $tag in *\) # Count slide id, insert "next" button - if [ "$stack" = "" ]; then - stack="${stack},section" + if [ "$depth" -eq 0 ]; then sl_pre="$sl_cur" sl_cur="${tag#*
}" sl_num="$((sl_num + 1))" @@ -70,22 +70,21 @@ wiki "$page" | { "${tag%
) # Count slide id, insert "next" button # *force* unwrapping from containing H1 section - if [ "$stack" = ",section" ]; then + if [ "$depth" -eq 1 ]; then printf '%s
\nprevious' \ "${tag%}" sl_num="$((sl_num + 1))" @@ -93,51 +92,46 @@ wiki "$page" | { printf '%snext\n
) # Insert "previous" button - if [ "$stack" = ",section" ]; then + if [ "$depth" -eq 1 ]; then printf '%s\nprevious' \ "${tag}" "$sl_pre" - elif [ "$stack" = "" ]; then - : + elif [ "$depth" -eq 0 ]; then + : # ignore "hanging" closing tag from unwrapped H1 section else printf %s "${tag}" fi - stack="${stack%,section}" - tag='' depth=$((depth - 1)) - ;; - *\<*\ class=\"uncover\"*\>) # Insert checkboxes in "uncover" lists - # printf '%s
  • ' "$tag" - printf '%s' "$tag" - tag="${tag#*<}" tag="${tag%%[ >]*}" - stack="${stack},${tag}" - tag='' depth=$((depth + 1)) - ucdepth=$((depth + 1)) + depth=$((depth - 1)) + tag='' ;; *\) printf %s "$tag" - stack="${stack%,*}" - tag='' depth=$((depth - 1)) + depth=$((depth - 1)) [ $depth -lt $ucdepth ] && ucdepth=-1 + tag='' ;; *\<*/\>|*\|*\|*\) printf %s "$tag" tag='' ;; - *\<*\>*) - if [ $ucdepth = $depth ]; then + *\<*\ class=\"uncover\"*\>) # Insert checkboxes in "uncover" lists + printf '%s' "$tag" + depth=$((depth + 1)) + ucdepth=$((depth + 1)) + tag='' + ;; + *\<*\>) + if [ $ucdepth -eq $depth ]; then printf '%s<%s' "${tag%<*}" "${tag#*<}" else printf %s "$tag" fi - [ "${tag}" = "${tag%/>}" ] && depth=$((depth + 1)) - tag="${tag#*<}" tag="${tag%%[ >]*}" - stack="${stack},${tag}" + depth=$((depth + 1)) tag='' ;; *) :