Summary Files Commits Branches @commit @diff @stats
path: root / awk-edits / Header-title.awk
diff options
context:
space:
mode:
Commit15c884e8dcaca3d7e95a5a8e513a682d555cf06c (patch)
Author
 Syndamia <kamen@syndamia.com>
2023-09-10 13:03:08 +0300
Committer
 Syndamia <kamen@syndamia.com>
2023-09-10 13:03:08 +0300
Files6868a68f65653cca6f5ab127cc432904ffb7dfbf /awk-edits/Header-title.awk
syndamia.com-15c884e8dcaca3d7e95a5a8e513a682d555cf06c.tar
syndamia.com-15c884e8dcaca3d7e95a5a8e513a682d555cf06c.tar.gz
syndamia.com-15c884e8dcaca3d7e95a5a8e513a682d555cf06c.zip
Parentf8476b4b1bf95fb511b480428ad25f594bf5ea5f (diff)
[Header-title] Added ending semicolumns and fixed bad text when HTML character code
1 files changed, 11 insertions, 9 deletions
-rw-r--r--awk-edits/Header-title.awk20
diff --git a/awk-edits/Header-title.awk b/awk-edits/Header-title.awk
index 16247e8..42fafa7 100644
--- a/awk-edits/Header-title.awk
+++ b/awk-edits/Header-title.awk
@@ -7,20 +7,22 @@
# inside first h1 header tag.
BEGIN {
- h1Index = 0
+ 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
+ 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)
+ # Removes the opening tag
+ gsub(/<h1[^>]*>/, "");
+ # Remove all HTML character codes, since they're in the form "&...;" and the &
+ # will be treated as the character for replacement in gsub
+ gsub(/&[^;]*;/, "");
+ title = substr($0, h1Index, index($0, "</h1") - h1Index);
}
-"\\[TITLE\\]" {
- gsub("\\[TITLE\\]", title)
+/\[TITLE\]/ {
+ gsub(/\[TITLE\]/, title);
}