aboutsummaryrefslogtreecommitdiff
path: root/v2/src/bin
diff options
context:
space:
mode:
authorEuAndreh <eu@euandre.org>2023-04-05 19:51:26 -0300
committerEuAndreh <eu@euandre.org>2023-04-05 19:51:26 -0300
commitc9d211aa4764a21d436417e2e19a349f61edc789 (patch)
tree9c884032efcf49411b1c84d75602c18d7a529d15 /v2/src/bin
parentv2: src/bin/html: Remove slugify_once() (diff)
downloadeuandre.org-c9d211aa4764a21d436417e2e19a349f61edc789.tar.gz
euandre.org-c9d211aa4764a21d436417e2e19a349f61edc789.tar.xz
v2: src/bin/html: Turn add_headings_anchors() into a parentheses fn
Diffstat (limited to 'v2/src/bin')
-rwxr-xr-xv2/src/bin/html42
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() {