X-Git-Url: http://git.plutz.net/?a=blobdiff_plain;ds=sidebyside;f=macros%2Ftoc;h=ed046e7bb6f22e95516849920c0c1cb3d0fc6470;hb=640be3bc5b7e3988475e741ad56d1953284a2dcf;hp=308fceda9cab6ea6b52c8004cdfe603bdcaf366a;hpb=801a5a731ec85902cd7eba7c4d42e5681e1df40f;p=shellwiki diff --git a/macros/toc b/macros/toc index 308fced..ed046e7 100755 --- a/macros/toc +++ b/macros/toc @@ -1,19 +1,28 @@ #!/bin/sh -. "$_EXEC/cgilite/cgilite.sh" +# Copyright 2022 - 2023 Paul Hänsch +# +# Permission to use, copy, modify, and/or distribute this software for any +# purpose with or without fee is hereby granted, provided that the above +# copyright notice and this permission notice appear in all copies. +# +# THE SOFTWARE IS PROVIDED âAS ISâ AND THE AUTHOR DISCLAIMS ALL WARRANTIES +# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +# SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR +# IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -unset MD_MACROS +. "$_EXEC/cgilite/cgilite.sh" -if [ "$(which awk)" ]; then - md() { awk -f "$_EXEC/cgilite/markdown.awk"; } -elif [ "$(which busybox)" ]; then - md() { busybox awk -f "$_EXEC/cgilite/markdown.awk"; } -else - md() { cat; } -fi +min="${1:-1}" max="${2:-6}" +[ "$min" -ge 1 -a "$min" -le 6 ] || min=1 +[ "$max" -ge "$min" ] || max="$min" +[ "$max" -le 6 ] || max=6 -md |sed -nE ' +sed -nE ' 1i
'