personal-website

source for my personal website regexghost.com
git clone https://git.regexghost.com/personal-website.git
Log | Files | Refs | README

header-ids.sh (421B)


      1 #!/bin/sh
      2 
      3 awk '{
      4 		if ($0 ~ /<h[1-6]>[^<]*<\/h[1-6]>/) { \
      5 			line = $0; \
      6 			sub(/[ \t]*<h/, "", line); \
      7 			level = line; \
      8 			sub(/>[^<]*<\/h[1-6].*/, "", level); \
      9 			title = line; \
     10 			sub(/^[1-6]>/, "", title); \
     11 			sub(/<\/h[1-6].*/, "", title);
     12 			id = title; \
     13 			gsub(/[^a-zA-Z0-9]/, "-", id); \
     14 			gsub(/---/, "-", id); \
     15 			$0 = "<h" level " id=\"" tolower(id) "\">" title "</h" level ">" \
     16 	} \
     17 	print \
     18 }'