diff options
[Header-description] More optimizations by replacing match with index
1 files changed, 4 insertions, 4 deletions
| -rw-r--r-- | awk-edits/Header-description.awk | 8 |
diff --git a/awk-edits/Header-description.awk b/awk-edits/Header-description.awk index 645a1ac..cdadf4d 100644 --- a/awk-edits/Header-description.awk +++ b/awk-edits/Header-description.awk @@ -28,17 +28,17 @@ BEGIN { # 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]) { - if (match($0, /<h[23456]/) && substr($0, RSTART, 17) != "<h2 id=\"contents\"") + if ((index($0, "<h1") || index($0, "<h2")) && substr($0, RSTART, 17) != "<h2 id=\"contents\"") break; - if (match($0, /^<p>/)) + if (index($0, "<p>")) parstar = 4; - if (match($0, /<\/p>$/)) + if (index($0, "</p>")) parends = 3; if (parcont || parstar == 4) { if (appToDesc($0)) break; - parcont = RSTART == 0; + parcont = parends == 0; parstar = 1; parends = 0; } |