Summary Files Commits Branches @commit @diff @stats
path: root / awk-edits / Header-description.awk
diff options
context:
space:
mode:
1 files changed, 0 insertions, 52 deletions
-rw-r--r--awk-edits/Header-description.awk52
diff --git a/awk-edits/Header-description.awk b/awk-edits/Header-description.awk
deleted file mode 100644
index f7c6ff4..0000000
--- a/awk-edits/Header-description.awk
+++ /dev/null
@@ -1,52 +0,0 @@
-#
-# == About ==
-#
-# Every page has a description and og:description meta tags. These descriptions are
-# generated from the text inside paragraphs of the current page.
-# The value for those meta tags is "[DESCRIPTION]" and it gets replaced with
-# either all of the text on the page, or only the first 200 characters.
-
-function appToDesc(l) {
- l = substr(l, parstar, length(l) - parstar + 1 - parend);
- gsub("<[^>]*>", "", l); gsub("&#8217;", "'", l); gsub(/&[^;]*;/, "", l);
-
- if (desc == "") desc = l;
- else desc = desc " " l;
-
- if (length(desc) >= 200) {
- desc = substr(desc, 1, 197) "...";
- return 1;
- }
- return 0;
-}
-
-BEGIN {
- parcont = 0; # continue, we have found a <p> but not a </p>
- parstar = 1; # we found a <p>
- parends = 0; # we found a </p>
-
- # Loop over the whole file, extract all text in first couple of paragraphs,
- # store it in desc (but no more than 200 characters will be saved)
- while(getline < ARGV[1]) {
- start = index($0, "<h2")
- if (start && substr($0, start, 16) != "<h2 id=\"contents")
- break;
-
- if (index($0, "<p>"))
- parstar = 4;
- if (index($0, "</p>"))
- parends = 3;
-
- if (parcont || parstar == 4) {
- if (appToDesc($0)) break;
- parcont = parends == 0;
- parstar = 1;
- parends = 0;
- }
- }
- close(ARGV[1]); # FILENAME isn't set during BEGIN
-}
-
-/\[DESCRIPTION\]/ {
- sub(/\[DESCRIPTION\]/, desc);
-}