diff options
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() { |