Summary Files Commits Branches @commit @diff @stats
path: root / generate-hooks / make-descriptions.sh
diff options
context:
space:
mode:
1 files changed, 3 insertions, 13 deletions
-rwxr-xr-xgenerate-hooks/make-descriptions.sh16
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</p" from current file
- # remove the "p>" and "</p" from result
- # make everything that starts with "<" blank
- # take all lines that aren't blank
- description=$(egrep -o "p>[^&]([^&]+)<\/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