Summary Files Commits Branches @commit @diff @stats
path: root / generate-hooks / make-titles.sh
diff options
context:
space:
mode:
Commit62daf522a1e51c4a1d9d8b31d2a0093da86ebc5d (patch)
Author
 Syndamia <kamen@syndamia.com>
2022-09-28 17:15:36 +0300
Committer
 Syndamia <kamen@syndamia.com>
2022-09-29 17:40:09 +0300
Files7474bc314afde18b6e53bb6702f54a04c5a87ed1 /generate-hooks/make-titles.sh
syndamia.com-62daf522a1e51c4a1d9d8b31d2a0093da86ebc5d.tar
syndamia.com-62daf522a1e51c4a1d9d8b31d2a0093da86ebc5d.tar.gz
syndamia.com-62daf522a1e51c4a1d9d8b31d2a0093da86ebc5d.zip
Parenta8b5c3c03b37ebf90e7ee8c9cb7c8f913f50c79a (diff)
[hooks] Reworked all hooks to use awk for their logic
1 files changed, 4 insertions, 7 deletions
-rwxr-xr-xgenerate-hooks/make-titles.sh11
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