From c9d211aa4764a21d436417e2e19a349f61edc789 Mon Sep 17 00:00:00 2001 From: EuAndreh Date: Wed, 5 Apr 2023 19:51:26 -0300 Subject: v2: src/bin/html: Turn add_headings_anchors() into a parentheses fn --- v2/src/bin/html | 42 ++++++++++++++++++++---------------------- 1 file changed, 20 insertions(+), 22 deletions(-) (limited to 'v2/src/bin') 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"; then - printf '%s\n' "$line" - continue - fi - LVL="$(printf '%s' "$line" | sed "s|^$INDENT.*|\1|")" - HEADING="$(printf '%s' "$line" | sed "s|^$INDENT\(.*\)$|\1|")" - SLUG="$(slugify "$HEADING")" - printf '%s%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"; then + printf '%s\n' "$line" + continue + fi + LVL="$(printf '%s' "$line" | sed "s|^$INDENT.*|\1|")" + HEADING="$(printf '%s' "$line" | sed "s|^$INDENT\(.*\)$|\1|")" + SLUG="$(slugify "$HEADING")" + printf '%s%s\n' \ + "$INDENT" \ + "$LVL" \ + "$SLUG" \ + "$HEADING" \ + "$SLUG" \ + "${icon_link_url:?}" \ + "$LVL" + done +) warn_duplicate_ids() { -- cgit v1.2.3