summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2024-04-21 13:46:34 +0300
committerPaul Buetow <paul@buetow.org>2024-04-21 13:46:34 +0300
commitf64c090bac0741963acef6193440d56fc6fbd48f (patch)
tree055eae1d58ad8aee8879ee2eb18e9958b1e39b77
parent3b2c08c38d33b54c5e4af61933cede43f40e855c (diff)
ignore bare blocks for toc generation
-rw-r--r--lib/template.source.sh10
1 files changed, 9 insertions, 1 deletions
diff --git a/lib/template.source.sh b/lib/template.source.sh
index a18e00f..29d0bf4 100644
--- a/lib/template.source.sh
+++ b/lib/template.source.sh
@@ -94,7 +94,15 @@ template::inline::index () {
template::inline::toc () {
echo '```'
echo 'Table of contents:'
- $GREP '^#' "$(basename "$CURRENT_TPL")" | $SED -E -n '/^#+ / { s/#/ /g; s/^ //; p; }'
+ < "$(basename "$CURRENT_TPL")" $SED -E -n '
+ /^```/,/^```/! {
+ /^#+ / {
+ s/#/ /g
+ s/^ //
+ p
+ }
+ }
+ '
echo '```'
}