diff options
| author | Paul Buetow <paul@buetow.org> | 2024-08-24 19:18:51 +0300 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2024-08-24 19:18:51 +0300 |
| commit | 3414d142ca5cad945657c2996f924db34da79c3d (patch) | |
| tree | 3adbd4417a417f352f88293c27ce1d2339502ae7 /lib | |
| parent | d64661ccdf837bb66c3268cb4415c56ba033f515 (diff) | |
change toc format and fix a bug
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/html.source.sh | 10 | ||||
| -rw-r--r-- | lib/md.source.sh | 4 | ||||
| -rw-r--r-- | lib/template.source.sh | 4 |
3 files changed, 9 insertions, 9 deletions
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 "<a href='#$id')'>$(html::encode "$text")</a>" + echo "<a href='#$id'>$(html::encode "$text")</a>" } # 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 } } |
