From 3414d142ca5cad945657c2996f924db34da79c3d Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Sat, 24 Aug 2024 19:18:51 +0300 Subject: change toc format and fix a bug --- lib/html.source.sh | 10 +++++----- lib/md.source.sh | 4 ++-- lib/template.source.sh | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-) (limited to 'lib') diff --git a/lib/html.source.sh b/lib/html.source.sh index 4be36df..543a459 100644 --- a/lib/html.source.sh +++ b/lib/html.source.sh @@ -141,7 +141,7 @@ html::source_highlight () { html::list::encode () { local text="$1"; shift - if [[ "$text" != ':'* ]]; then + if [[ "$text" != '⇢ '* ]]; then # No ToC html::encode "$text" return @@ -150,19 +150,19 @@ html::list::encode () { local -i toc_indent=0 # If there's a . (dot) in the liste element, it then indicates a ToC element - while [[ "$text" == ':'* ]]; do - text="$($SED 's/://' <<< "$text")" + while [[ "$text" == '⇢ '* ]]; do + text="$($SED 's/⇢ //' <<< "$text")" : $(( toc_indent++ )) done while [ $toc_indent -ge 2 ]; do - echo -n '      ' + echo -n '⇢ ' : $(( toc_indent-- )) done text="${text/ /}" local -r id="$(generate::internal_link_id "$text")" - echo "$(html::encode "$text")" + echo "$(html::encode "$text")" } # Convert Gemtext to HTML diff --git a/lib/md.source.sh b/lib/md.source.sh index 8478812..7e7e6c8 100644 --- a/lib/md.source.sh +++ b/lib/md.source.sh @@ -27,7 +27,7 @@ md::make_link () { md::make_toc_link () { local -r descr="$1"; shift - local -r text="${descr/ /}" + local -r text="$($SED -E 's/⇢ //g' <<< "$descr")" echo "[$descr](#$(generate::internal_link_id "$text"))" } @@ -38,7 +38,7 @@ md::fromgmi () { '=> '*) generate::make_link md "$line" ;; - '* :'*) + '* ⇢'*) echo -n '* ' md::make_toc_link "${line/\* /}" ;; diff --git a/lib/template.source.sh b/lib/template.source.sh index 7689728..88eba0f 100644 --- a/lib/template.source.sh +++ b/lib/template.source.sh @@ -97,8 +97,8 @@ template::inline::toc () { < "$(basename "$CURRENT_TPL")" $SED -E -n ' /^```/,/^```/! { /^#+ / { - s/#/* :/ - s/#/:/g + s/#/* ⇢/ + s/#/ ⇢/g p } } -- cgit v1.2.3