]> git.plutz.net Git - shellwiki/commitdiff
div wrapper and page links for include macro
authorPaul Hänsch <paul@plutz.net>
Thu, 19 May 2022 14:20:51 +0000 (16:20 +0200)
committerPaul Hänsch <paul@plutz.net>
Thu, 19 May 2022 14:20:51 +0000 (16:20 +0200)
macros/include

index d35c2a30c625a5b9938971a9411e9fc6978a948a..9f3339df5201e617ebfb443d7dc9f3575771eead 100755 (executable)
@@ -34,6 +34,7 @@ if ! printf %s\\n "$items" |grep -qEx '\$|[0-9]+'; then
   exit 1
 fi
 
+printf '<div class="macro include wrapper">'
 page_glob "$page" \
 | sort $rev \
 | sed "${items}q" \
@@ -50,8 +51,9 @@ page_glob "$page" \
   else
     continue
   fi
-  printf '<div class="macro include" page="%s">' "$(HTML "$glob")"
-  refpfx="$(HTML "$glob" |sed 's;[\;&\;];\\&;g')"
+  hglob="$(HTML "$glob")"
+  refpfx="$(printf %s\\n "$hglob" |sed 's;[\;&\;];\\&;g')"
+  printf '<div class="macro include page"><article class="include" id="include_%s">' "${hglob}"
   ( cd -- "${mdfile%/*}"
     sed -n "${from},${to}p" <"$mdfile" \
     | md \
@@ -61,5 +63,8 @@ page_glob "$page" \
     s;(<[^>]+ )(href|src)="([^#/"][^"]*)"([^>]*>);\1\2="'"${refpfx}"'\3"\4;g
     s;(<[^>]+ )(href|src)="/#safe/([^"]*)"([^>]*>);\1\2="\3"\4;g
   '
+  printf '</article>'
+  printf '<a class="include link" href="%s">%s</a>' "${hglob}" "${hglob}"
   printf '</div>'
 done
+printf '</div>'