From 38cc8bcf5bd45d61ccddad9fb3dc8aca202364cf Mon Sep 17 00:00:00 2001 From: Louie Shprung Date: Sun, 18 Dec 2022 10:10:43 -0800 Subject: Subheaders are created as guides --- src/index.sh | 17 ++++++++++------- 1 file 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=".*" + 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 '&' 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 -- cgit