diff options
author | Louie Shprung <lshprung@scu.edu> | 2022-12-18 17:45:55 -0800 |
---|---|---|
committer | Louie Shprung <lshprung@scu.edu> | 2022-12-18 17:45:55 -0800 |
commit | debbcda7d7b87edc4440a3a34459cdce5e63542c (patch) | |
tree | d1100a3df90485db76636eaacebcf592bf6b8c3a /src | |
parent | 38cc8bcf5bd45d61ccddad9fb3dc8aca202364cf (diff) |
Working subheader anchors
Diffstat (limited to 'src')
-rwxr-xr-x | src/index.sh | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/index.sh b/src/index.sh index 218cee0..298a0d9 100755 --- a/src/index.sh +++ b/src/index.sh @@ -11,7 +11,7 @@ get_title() { #Find pattern in file grep -Eo "$PATTERN" "$FILE" | #Remove tag - sed 's/<[^>]*>//g' | \ + sed 's/<[^>]*>//' | \ #Remove leading chapter #sed 's/^[A-Z0-9]\.*[^ ]* //g' | \ #Remove trailing space @@ -33,13 +33,16 @@ sqlite3 "$DB_PATH" "CREATE TABLE searchIndex(id INTEGER PRIMARY KEY, name TEXT, sqlite3 "$DB_PATH" "CREATE UNIQUE INDEX anchor ON searchIndex (name, type, path);" # 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")" echo "$PAGE_NAME" | while read -r line; do if [ -n "$line" ]; then - insert "$line" "Guide" "$(basename "$1")" + unset TITLE + TITLE="$(echo "$line" | sed 's/<[^>]*>//g')" + unset LINK + LINK="$(basename "$1")#$(echo "$line" | sed 's/^.\{7\}//' | sed 's/\"\/>.*//')" + insert "$TITLE" "Guide" "$LINK" fi done shift |