aboutsummaryrefslogtreecommitdiff
path: root/gen
diff options
context:
space:
mode:
authorCollin Williams <96917990+bluedragon1221@users.noreply.github.com>2024-10-26 14:20:53 -0500
committerCollin Williams <96917990+bluedragon1221@users.noreply.github.com>2024-10-26 14:20:53 -0500
commite9876ed63800bb91ff0395a8863992993dc816f9 (patch)
tree2b0725e85c49addcc794e1d4cca0ade77fffe25d /gen
parente637325301bd38d74acb69840164fc74a9d86fb3 (diff)
write script to generate life lessons index
Diffstat (limited to 'gen')
-rwxr-xr-xgen/gen_life_lessons.sh20
1 files changed, 20 insertions, 0 deletions
diff --git a/gen/gen_life_lessons.sh b/gen/gen_life_lessons.sh
new file mode 100755
index 0000000..c766964
--- /dev/null
+++ b/gen/gen_life_lessons.sh
@@ -0,0 +1,20 @@
+#!/usr/bin/env bash
+
+echo -e "---\ntitle: Index of Life Lessons\n---\n"
+
+echo -e "_This is a listing of all the life lessons portrayed in the stories of this book and the corresponding story title. It is hoped that this listing will help the reader find the story they are looking for more quickly. The numbers refer to the numbers in the story titles in the collection of digital files that accompany this book._\n"
+
+echo "| Life Lesson | Title |"
+echo "|---|---|"
+
+for i in $(find md -maxdepth 1 -name "*.md" -printf '%f\n'); do
+ (
+ title=$(sed -nE 's/^title: "?([^"]+)"?$/\1/p' "md/$i")
+ lesson=$(sed -nE 's/^lesson: "?([^"]+)"?$/\1/p' "md/$i")
+ filename="${i%.*}"
+
+ [ -n "$lesson" ] && echo "$lesson" | tr ";" "\n" | xargs -I {} -d'\n' printf "| {} | [$title](/stories/${filename}.html) |\n"
+ ) &
+done
+
+wait