diff options
author | EuAndreh <eu@euandre.org> | 2023-04-05 19:51:26 -0300 |
---|---|---|
committer | EuAndreh <eu@euandre.org> | 2023-04-05 19:51:26 -0300 |
commit | c9d211aa4764a21d436417e2e19a349f61edc789 (patch) | |
tree | 9c884032efcf49411b1c84d75602c18d7a529d15 /v2/src/bin | |
parent | v2: src/bin/html: Remove slugify_once() (diff) | |
download | euandre.org-c9d211aa4764a21d436417e2e19a349f61edc789.tar.gz euandre.org-c9d211aa4764a21d436417e2e19a349f61edc789.tar.xz |
v2: src/bin/html: Turn add_headings_anchors() into a parentheses fn
Diffstat (limited to '')
-rwxr-xr-x | v2/src/bin/html | 42 |
1 files changed, 20 insertions, 22 deletions
diff --git a/v2/src/bin/html b/v2/src/bin/html index 922b56e..38270b1 100755 --- a/v2/src/bin/html +++ b/v2/src/bin/html @@ -170,28 +170,26 @@ add_line_numbers() { ' } -add_headings_anchors() { - ( - IFS='' - while read -r line; do - if ! printf '%s' "$line" | grep -q "^$INDENT<h[2-6]>"; then - printf '%s\n' "$line" - continue - fi - LVL="$(printf '%s' "$line" | sed "s|^$INDENT<h\(.\)>.*|\1|")" - HEADING="$(printf '%s' "$line" | sed "s|^$INDENT<h.>\(.*\)</h.>$|\1|")" - SLUG="$(slugify "$HEADING")" - printf '%s<h%s class="header-anchor" id="%s">%s<a href="#%s" aria-hidden="true"><img class="svg-icon" src="%s" /></a></h%s>\n' \ - "$INDENT" \ - "$LVL" \ - "$SLUG" \ - "$HEADING" \ - "$SLUG" \ - "${icon_link_url:?}" \ - "$LVL" - done - ) -} +add_headings_anchors() ( + IFS='' + while read -r line; do + if ! printf '%s' "$line" | grep -q "^$INDENT<h[2-6]>"; then + printf '%s\n' "$line" + continue + fi + LVL="$(printf '%s' "$line" | sed "s|^$INDENT<h\(.\)>.*|\1|")" + HEADING="$(printf '%s' "$line" | sed "s|^$INDENT<h.>\(.*\)</h.>$|\1|")" + SLUG="$(slugify "$HEADING")" + printf '%s<h%s class="header-anchor" id="%s">%s<a href="#%s" aria-hidden="true"><img class="svg-icon" src="%s" /></a></h%s>\n' \ + "$INDENT" \ + "$LVL" \ + "$SLUG" \ + "$HEADING" \ + "$SLUG" \ + "${icon_link_url:?}" \ + "$LVL" + done +) warn_duplicate_ids() { |