]> git.plutz.net Git - shellwiki/commitdiff
introduce --hl option to include macro
authorPaul Hänsch <paul@plutz.net>
Tue, 19 Sep 2023 12:00:35 +0000 (14:00 +0200)
committerPaul Hänsch <paul@plutz.net>
Tue, 19 Sep 2023 12:00:35 +0000 (14:00 +0200)
macros/include

index f6b3a34ced7f4c22b700b9b4886e1070c8c2f421..f3005849cb2c9be5bdba8ceb57bca2e73031a5b0 100755 (executable)
@@ -18,7 +18,7 @@
 . "$_EXEC/acl.sh"
 . "$_EXEC/tools.sh"
 
-from='1'; to='$'; rev=''; items='$'; link='true'
+from='1'; to='$'; rev=''; items='$'; hl=0; link='true'
 
 while [ $# -gt 0 ]; do case $1 in
   --from) from="$2"; shift 2;;
@@ -29,6 +29,7 @@ while [ $# -gt 0 ]; do case $1 in
   items=*) items="${1#*=}"; shift 1;;
   --rev|--reverse) rev="-r"; shift 1;;
   --nolink) link=""; shift 1;;
+  --hl|-hl) hl=$2; shift 2;;
   *) page="$1"; shift 1;;
 esac; done
 
@@ -72,6 +73,39 @@ page_glob "$page" \
     s;(<[^>]+ )(href|src)="([^"]+://[^"]*|[mM][aA][iI][lL][tT][oO]:[^"]*)"([^>]*>);\1\2="/#safe/\3"\4;g
     s;(<[^>]+ )(href|src)="([^#/"][^"]*)"([^>]*>);\1\2="'"${refpfx}"'\3"\4;g
     s;(<[^>]+ )(href|src)="/#safe/([^"]*)"([^>]*>);\1\2="\3"\4;g
-  '
+  ' | case $hl in
+      1) sed -E 's;(<h|</h)5( |>);\16\2;g;
+                 s;(<h|</h)4( |>);\15\2;g;
+                 s;(<h|</h)3( |>);\14\2;g;
+                 s;(<h|</h)2( |>);\13\2;g;
+                 s;(<h|</h)1( |>);\12\2;g;
+         ';;
+      2) sed -E 's;(<h|</h)5( |>);\16\2;g;
+                 s;(<h|</h)4( |>);\16\2;g;
+                 s;(<h|</h)3( |>);\15\2;g;
+                 s;(<h|</h)2( |>);\14\2;g;
+                 s;(<h|</h)1( |>);\13\2;g;
+         ';;
+      3) sed -E 's;(<h|</h)5( |>);\16\2;g;
+                 s;(<h|</h)4( |>);\16\2;g;
+                 s;(<h|</h)3( |>);\16\2;g;
+                 s;(<h|</h)2( |>);\15\2;g;
+                 s;(<h|</h)1( |>);\14\2;g;
+         ';;
+      4) sed -E 's;(<h|</h)5( |>);\16\2;g;
+                 s;(<h|</h)4( |>);\16\2;g;
+                 s;(<h|</h)3( |>);\16\2;g;
+                 s;(<h|</h)2( |>);\16\2;g;
+                 s;(<h|</h)1( |>);\15\2;g;
+         ';;
+      5|[6789])
+         sed -E 's;(<h|</h)5( |>);\16\2;g;
+                 s;(<h|</h)4( |>);\16\2;g;
+                 s;(<h|</h)3( |>);\16\2;g;
+                 s;(<h|</h)2( |>);\16\2;g;
+                 s;(<h|</h)1( |>);\16\2;g;
+         ';;
+      *) cat;;
+    esac
   printf '</article></div>'
 done