From 818e1db0599119b428436b4c2547b759150dd621 Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Sat, 24 Aug 2024 14:57:07 +0100 Subject: initial nicer markdown ToC support --- lib/html.source.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'lib/html.source.sh') diff --git a/lib/html.source.sh b/lib/html.source.sh index f30cb22..382f5e7 100644 --- a/lib/html.source.sh +++ b/lib/html.source.sh @@ -27,7 +27,7 @@ html::make_paragraph () { html::make_heading () { local -r text=$($SED -E 's/^#+ //' <<< "$1"); shift local -r level="$1"; shift - local -r id=$(tr -cd 'A-Za-z0-9' <<< "$text") + local -r id="$(generate::internal_link_id "$text")" if [ "$HTML_VARIANT_TO_USE" = exact ]; then echo "$(html::encode "$text")
" @@ -161,7 +161,7 @@ html::list::encode () { done text="${text/ /}" - local -r id=$(tr -cd 'A-Za-z0-9' <<< "$text") + local -r id="$(generate::internal_link_id "$text")" echo "$(html::encode "$text")" } @@ -329,15 +329,15 @@ html::test::exact () { assert::equals "$(html::make_paragraph "$line")" "echo foo 2>&1
" line='# Header 1' - local id=$(tr -cd 'A-Za-z0-9' <<< "$line") + local id='header-1' assert::equals "$(html::make_heading "$line" 1)" "

Header 1


" line='## Header 2' - id=$(tr -cd 'A-Za-z0-9' <<< "$line") + id='header-2' assert::equals "$(html::make_heading "$line" 2)" "

Header 2


" line='### Header 3' - id=$(tr -cd 'A-Za-z0-9' <<< "$line") + id='header-3' assert::equals "$(html::make_heading "$line" 3)" "

Header 3


" line='> This is a quote' -- cgit v1.2.3