From 62daf522a1e51c4a1d9d8b31d2a0093da86ebc5d Mon Sep 17 00:00:00 2001 From: Syndamia Date: Wed, 28 Sep 2022 17:15:36 +0300 Subject: [hooks] Reworked all hooks to use awk for their logic --- generate-hooks/make-descriptions.sh | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) (limited to 'generate-hooks/make-descriptions.sh') diff --git a/generate-hooks/make-descriptions.sh b/generate-hooks/make-descriptions.sh index 1ea7a9f..9895f2e 100755 --- a/generate-hooks/make-descriptions.sh +++ b/generate-hooks/make-descriptions.sh @@ -5,21 +5,11 @@ if [ -z "$1" ]; then exit fi -# Loop through all HTML files in given directory - # Get text that matches "p>any amount of characters" and "[^&]([^&]+)<\/p" $file | sed "s/p>\|<\/p//g;s/<.*//g" | grep .) - - # Get the first 200 characters only when it's longer than 200 characters - if [ ${#description} -gt 200 ]; then - description="${description::200}..." - fi +awkloc="$(dirname "$0")/create-description.awk" - # Escape all non-acceptable characters (thanks https://www.unix.com/302989284-post3.html) - description=$(echo $description | sed 's/[^a-zA-Z 0-9]/\\&/g') +# Loop through all HTML files in given directory for file in $1; do + description=$(awk -f "$awkloc" $file) # Replace all "[DESCRIPTION]" text in current file with what we selected (inside description) sed -i "s/\[DESCRIPTION\]/$description/g" $file -- cgit v1.3.1-26-gb76a