From: Paul Hänsch Date: Thu, 13 Oct 2022 13:44:09 +0000 (+0200) Subject: --nolink option for include macro X-Git-Url: https://git.plutz.net/?a=commitdiff_plain;h=7defc340d721f26e33c0fa1df0e233c69b53c54a;p=shellwiki --nolink option for include macro --- diff --git a/macros/include b/macros/include index 5eb613a..5254a26 100755 --- a/macros/include +++ b/macros/include @@ -4,7 +4,7 @@ . "$_EXEC/acl.sh" . "$_EXEC/tools.sh" -from='1'; to='$'; rev=''; items='$' +from='1'; to='$'; rev=''; items='$'; link='true' while [ $# -gt 0 ]; do case $1 in --from) from="$2"; shift 2;; @@ -14,6 +14,7 @@ while [ $# -gt 0 ]; do case $1 in --items) items="$2"; shift 2;; items=*) items="${1#*=}"; shift 1;; --rev|--reverse) rev="-r"; shift 1;; + --nolink) link=""; shift 1;; *) page="$1"; shift 1;; esac; done @@ -21,7 +22,7 @@ if ! printf %s\\n "$from" |grep -qEx '[0-9]+|/([^/\\]|\\/|\\.)*/'; then debug 'Include macro invalid argument: "from"' exit 1 fi -if ! printf %s\\n "$to" |grep -qEx '[0-9]+|/([^/\\]|\\/|\\.)*/'; then +if ! printf %s\\n "$to" |grep -qEx '\$|[0-9]+|/([^/\\]|\\/|\\.)*/'; then debug 'Include macro Invalid argument: "to"' exit 1 fi @@ -39,10 +40,14 @@ page_glob "$page" \ mdfile="$(mdfile "$page")" || continue hglob="$(HTML "$glob")" refpfx="$(printf %s\\n "$hglob" |sed 's;[\;&\;];\\&;g')" - printf '
- %s -
' \ - "${hglob}" "${hglob}" "${hglob}" + [ "$link" ] \ + && printf '
+ %s +
' \ + "${hglob}" "${hglob}" "${hglob}" \ + || printf '
+
' \ + "${hglob}" ( # PATH_INFO may be used by macros in the included page export PATH_INFO="$page" cd -- "${mdfile%/*}/"