summaryrefslogtreecommitdiff
path: root/src/index.sh
diff options
context:
space:
mode:
Diffstat (limited to 'src/index.sh')
-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