summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2024-12-30 10:21:09 +0200
committerPaul Buetow <paul@buetow.org>2024-12-30 10:21:09 +0200
commitf5e2d2edc4ab9f2842ef5cdca0ce1a130ce6f0a7 (patch)
treefc56651f9e815d9f12cc90d0b500d008dc0257d5
parentc1595f6b6d5df73ba626d29250fc79e4043e290b (diff)
fix toc when there are tags in them
-rw-r--r--extras/html/themes/retrosimple/style.css1
-rw-r--r--lib/template.source.sh30
2 files changed, 29 insertions, 2 deletions
diff --git a/extras/html/themes/retrosimple/style.css b/extras/html/themes/retrosimple/style.css
index 6b11516..49e74ef 100644
--- a/extras/html/themes/retrosimple/style.css
+++ b/extras/html/themes/retrosimple/style.css
@@ -75,4 +75,5 @@ pre {
span.inlinecode {
font-family: courier, monospace;
+ border: 1px solid #666666;
}
diff --git a/lib/template.source.sh b/lib/template.source.sh
index 83dfb21..7bd3f93 100644
--- a/lib/template.source.sh
+++ b/lib/template.source.sh
@@ -103,6 +103,7 @@ template::inline::index () {
done | sort | uniq
}
+# TODO: Write unit test.
# To generate a table of contents
template::inline::toc () {
echo '## Table of Contents'
@@ -110,8 +111,9 @@ template::inline::toc () {
< "$(basename "$CURRENT_TPL")" $SED -E -n '
/^```/,/^```/! {
/^#+ / {
- s/#/* ⇢/
- s/#/ ⇢/g
+ s/^###/* ⇢ ⇢ ⇢/
+ s/^##/* ⇢ ⇢/
+ s/^#/* ⇢/
p
}
}
@@ -171,4 +173,28 @@ Just so that you know'
assert::equals "$(template::_generate <<< "$template5")" "$expect5"
assert::equals "$(template::_generate <<< ']')" '>'
+
+# local -r template6='# Hello world
+
+# << template::inline::toc
+
+# ## Heading 1
+
+# ### Heading 1b
+
+# foo bar baz
+
+# ## Heading 2
+
+# ### Heading 2b
+
+# foo bar baz'
+
+# local -r expect6='<< echo foo
+# <<<
+# echo bar
+# >>>'
+# assert::equals "$(template::_generate <<< "$template6")" "$expect6"
+
+# assert::equals "$(template::_generate <<< ']')" '>'
}