diff options
[hooks] Reworked all hooks to use awk for their logic
1 files changed, 18 insertions, 0 deletions
| -rw-r--r-- | generate-hooks/create-description.awk | 18 |
diff --git a/generate-hooks/create-description.awk b/generate-hooks/create-description.awk new file mode 100644 index 0000000..b4fac0e --- /dev/null +++ b/generate-hooks/create-description.awk @@ -0,0 +1,18 @@ +/p>.*/ { + # Removes tags and bad characters + gsub(/<[^>]*>/, "") ; gsub(/[^a-zA-Z0-9 ]/, "") + # Trims leading and trailing spaces and tabs (if any) + gsub(/^[ \t]*/, "") ; gsub(/[ \t]*$/, "") + + # Concatenates the current record to variable and shortens it, + # when it gets too long + desc = desc $0 + if (length(desc) >= 200) { + desc = substr(desc, 1, 197) "..." + exit + } +} + +END { + print desc +} |