diff options
| Commit | 23277fab3374caa00926be42ebaabacbb9e67fea (patch) | |
|---|---|---|
| Author | 2022-09-28 09:39:05 +0300 | |
| Committer | 2022-09-28 09:39:05 +0300 | |
| Files | 9e011f4a5fdcc0b92f41f7cd6dd33f3c0e1de14a | |
| syndamia.com-23277fab3374caa00926be42ebaabacbb9e67fea.tar syndamia.com-23277fab3374caa00926be42ebaabacbb9e67fea.tar.gz syndamia.com-23277fab3374caa00926be42ebaabacbb9e67fea.zip | ||
| Parent | 64715a1132aab0bb8e2964db110da7c3b1336078 (diff) | |
[hooks] Slightly optimized sed patterns
2 files changed, 8 insertions, 13 deletions
| -rwxr-xr-x | generate-hooks/make-descriptions.sh | 2 | ||||
| -rwxr-xr-x | generate-hooks/make-file-lists.sh | 19 |
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" 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" | 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 "<table class="file-list"><tr>" - sed -i 's/&&nos$/<table class="file-list"><tr>/g' "$file" - # Replaces "&&fos" with "<details class="file-wrapper"><summary>" - sed -i 's/^<p>&&fos$/<details class="file-wrapper"><summary>/g' "$file" - # Replaces "&&fs0" with "</summary><table class="file-list"><tr>" - sed -i 's/^&&fs0$/<\/summary><table class="file-list"><tr>/g' "$file" - # Replaces "&&fs" with "</tr><tr>" - sed -i 's/^&&fs$/<\/tr><tr>/g' "$file" - # Replaces "&&nod" with "</tr></table>" - sed -i 's/^&&nod<\/p>$/<\/tr><\/table>/g' "$file" - # Replaces "&&fod" with "</tr></table></details>" - sed -i 's/^&&fod<\/p>$/<\/tr><\/table><\/details>/g' "$file" + sed -i 's/&&nos$/<table class="file-list"><tr>/g; + s/^<p>&&fos$/<details class="file-wrapper"><summary>/g; + s/^&&fs0$/<\/summary><table class="file-list"><tr>/g; + s/^&&fs$/<\/tr><tr>/g; + s/^&&nod<\/p>$/<\/tr><\/table>/g; + s/^&&fod<\/p>$/<\/tr><\/table><\/details>/g' \ + "$file" done |