From 23277fab3374caa00926be42ebaabacbb9e67fea Mon Sep 17 00:00:00 2001 From: Syndamia Date: Wed, 28 Sep 2022 09:39:05 +0300 Subject: [hooks] Slightly optimized sed patterns --- generate-hooks/make-descriptions.sh | 2 +- generate-hooks/make-file-lists.sh | 19 +++++++------------ 2 files changed, 8 insertions(+), 13 deletions(-) diff --git a/generate-hooks/make-descriptions.sh b/generate-hooks/make-descriptions.sh index 1a4ace4..8268019 100755 --- a/generate-hooks/make-descriptions.sh +++ b/generate-hooks/make-descriptions.sh @@ -11,7 +11,7 @@ for file in $(find "$1" -type f -name "*.html"); do # remove the "p>" and "[^&]([^&]+)<\/p" $file | sed "s/p>\|<\/p//g" | sed "s/<.*//g" | grep .) + 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 diff --git a/generate-hooks/make-file-lists.sh b/generate-hooks/make-file-lists.sh index 33b5e48..a930e9d 100755 --- a/generate-hooks/make-file-lists.sh +++ b/generate-hooks/make-file-lists.sh @@ -54,16 +54,11 @@ if [ -z "$1" ]; then fi for file in $(find "$1" -type f -name "*.html"); do - # Replaces "&&nos" with "" - sed -i 's/&&nos$/
/g' "$file" - # Replaces "&&fos" with "
" - sed -i 's/^

&&fos$/

/g' "$file" - # Replaces "&&fs0" with "
" - sed -i 's/^&&fs0$/<\/summary>
/g' "$file" - # Replaces "&&fs" with "" - sed -i 's/^&&fs$/<\/tr>/g' "$file" - # Replaces "&&nod" with "
" - sed -i 's/^&&nod<\/p>$/<\/tr><\/table>/g' "$file" - # Replaces "&&fod" with "" - sed -i 's/^&&fod<\/p>$/<\/tr><\/table><\/details>/g' "$file" + sed -i 's/&&nos$//g; + s/^

&&fos$/

/g; + s/^&&fs0$/<\/summary>
/g; + s/^&&fs$/<\/tr>/g; + s/^&&nod<\/p>$/<\/tr><\/table>/g; + s/^&&fod<\/p>$/<\/tr><\/table><\/details>/g' \ + "$file" done -- cgit v1.3.1-26-gb76a