summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLouie Shprung <lshprung@scu.edu>2022-12-18 10:10:43 -0800
committerLouie Shprung <lshprung@scu.edu>2022-12-18 10:10:43 -0800
commit38cc8bcf5bd45d61ccddad9fb3dc8aca202364cf (patch)
tree12ea4283afeea3449201c8eb259c474f36bde070
parent92aa328472ba76197a6036628e6796f4b9ffeed0 (diff)
Subheaders are created as guides
-rwxr-xr-xsrc/index.sh17
1 files changed, 10 insertions, 7 deletions
diff --git a/src/index.sh b/src/index.sh
index be1a508..218cee0 100755
--- a/src/index.sh
+++ b/src/index.sh
@@ -6,14 +6,14 @@ shift
get_title() {
FILE="$1"
- PATTERN="<title>.*</title>"
+ PATTERN="<.*class=\"title\">.*"
#Find pattern in file
grep -Eo "$PATTERN" "$FILE" |
#Remove tag
sed 's/<[^>]*>//g' | \
- #Remove '(automake)'
- sed 's/(automake)//g' | \
+ #Remove leading chapter
+ #sed 's/^[A-Z0-9]\.*[^ ]* //g' | \
#Remove trailing space
sed 's/[ ]*$//g' | \
#Replace '&amp' with '&'
@@ -32,12 +32,15 @@ insert() {
sqlite3 "$DB_PATH" "CREATE TABLE searchIndex(id INTEGER PRIMARY KEY, name TEXT, type TEXT, path TEXT);"
sqlite3 "$DB_PATH" "CREATE UNIQUE INDEX anchor ON searchIndex (name, type, path);"
-# Get title and insert into table for each html file
+# Get titles and insert into table for each html file
+# TODO get page anchors working
while [ -n "$1" ]; do
unset PAGE_NAME
PAGE_NAME="$(get_title "$1")"
- if [ -n "$PAGE_NAME" ]; then
- insert "$PAGE_NAME" "Guide" "$(basename "$1")"
- fi
+ echo "$PAGE_NAME" | while read -r line; do
+ if [ -n "$line" ]; then
+ insert "$line" "Guide" "$(basename "$1")"
+ fi
+ done
shift
done