diff options
[hooks] Removed bash hook scripts and made awk scripts the way to generate the website
1 files changed, 21 insertions, 6 deletions
| -rw-r--r-- | generate-hooks/create-title.awk | 27 |
diff --git a/generate-hooks/create-title.awk b/generate-hooks/create-title.awk index 14d8ec6..f1eaa4f 100644 --- a/generate-hooks/create-title.awk +++ b/generate-hooks/create-title.awk @@ -1,7 +1,22 @@ -/<h1>.+/ { - # Takes everything between <h1> and </h1> in the first - # <h1> occurence. - h = index($0, "<h1>") - print substr($0, h, index($0, "</h1") - h) - exit +BEGIN { + h1Index = 0 + + # When this loop finishes, $0 will have the first line containing an h1 header + # tag, and h1Index will have it's starting position + while (h1Index == 0 && getline < ARGV[1]) + h1Index = index($0, "<h1") + close(ARGV[1]) # FILENAME isn't set during BEGIN + + # Removes the opening tag and substrings everything that is normally + # inside the heading tag + gsub(/<h1[^>]*>/, "") + title = substr($0, h1Index, index($0, "</h1") - h1Index) +} + +"\\[TITLE\\]" { + gsub("\\[TITLE\\]", title) +} + +{ + print } |