From e9876ed63800bb91ff0395a8863992993dc816f9 Mon Sep 17 00:00:00 2001 From: Collin Williams <96917990+bluedragon1221@users.noreply.github.com> Date: Sat, 26 Oct 2024 14:20:53 -0500 Subject: write script to generate life lessons index --- gen/gen_life_lessons.sh | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100755 gen/gen_life_lessons.sh (limited to 'gen/gen_life_lessons.sh') 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 -- cgit v1.3.1