diff options
| author | Paul Buetow <paul@buetow.org> | 2024-08-24 14:57:07 +0100 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2024-08-24 14:57:07 +0100 |
| commit | 818e1db0599119b428436b4c2547b759150dd621 (patch) | |
| tree | 44317ba89eca917895ca333cc039ffadd881d6dd /lib/html.source.sh | |
| parent | a0cdf880c32264165f1af87d7f0465d3923ffe88 (diff) | |
initial nicer markdown ToC support
Diffstat (limited to 'lib/html.source.sh')
| -rw-r--r-- | lib/html.source.sh | 10 |
1 files changed, 5 insertions, 5 deletions
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 "<h${level} style='display: inline' id='${id}'>$(html::encode "$text")</h${level}><br />" @@ -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 "<a href='#$id')'>$(html::encode "$text")</a>" } @@ -329,15 +329,15 @@ html::test::exact () { assert::equals "$(html::make_paragraph "$line")" "<span>echo foo 2>&1</span><br />" line='# Header 1' - local id=$(tr -cd 'A-Za-z0-9' <<< "$line") + local id='header-1' assert::equals "$(html::make_heading "$line" 1)" "<h1 style='display: inline' id='${id}'>Header 1</h1><br />" line='## Header 2' - id=$(tr -cd 'A-Za-z0-9' <<< "$line") + id='header-2' assert::equals "$(html::make_heading "$line" 2)" "<h2 style='display: inline' id='${id}'>Header 2</h2><br />" line='### Header 3' - id=$(tr -cd 'A-Za-z0-9' <<< "$line") + id='header-3' assert::equals "$(html::make_heading "$line" 3)" "<h3 style='display: inline' id='${id}'>Header 3</h3><br />" line='> This is a quote' |
