diff options
[hooks] Reworked all hooks to use awk for their logic
1 files changed, 4 insertions, 7 deletions
| -rwxr-xr-x | generate-hooks/make-titles.sh | 11 |
diff --git a/generate-hooks/make-titles.sh b/generate-hooks/make-titles.sh index 1c9ebef..4bb70b9 100755 --- a/generate-hooks/make-titles.sh +++ b/generate-hooks/make-titles.sh @@ -5,15 +5,12 @@ if [ -z "$1" ]; then exit fi -# Loop through all HTML files in given directory - # Get text that matches "h1>any amount of characters</h1" from current file - # remove the "h1>" and "</h1" from result - title=$(egrep -o "h1(.+)>(.+)<\/h1" $file | sed "s/h1[^>]\+>\|<\/h1//g") +awkloc="$(dirname "$0")/create-title.awk" - # Escape all non-acceptable characters (thanks https://www.unix.com/302989284-post3.html) - title=$(echo $title | sed 's/[^a-zA-Z 0-9]/\\&/g') +# Loop through all HTML files in given directory for file in $1; do + title=$(awk -f "$awkloc" $file) - # Replace all "[TITLE]" text in current file with what we selected (inside title) + # Replace all "[TITLE]" text in current file with title sed -i "s/\[TITLE\]/$title/g" $file done |