Summary Files Commits Branches @commit @diff @stats
path: root / generate-hooks / create-description.awk
diff options
context:
space:
mode:
Commit62daf522a1e51c4a1d9d8b31d2a0093da86ebc5d (patch)
Author
 Syndamia <kamen@syndamia.com>
2022-09-28 17:15:36 +0300
Committer
 Syndamia <kamen@syndamia.com>
2022-09-29 17:40:09 +0300
Files7474bc314afde18b6e53bb6702f54a04c5a87ed1 /generate-hooks/create-description.awk
syndamia.com-62daf522a1e51c4a1d9d8b31d2a0093da86ebc5d.tar
syndamia.com-62daf522a1e51c4a1d9d8b31d2a0093da86ebc5d.tar.gz
syndamia.com-62daf522a1e51c4a1d9d8b31d2a0093da86ebc5d.zip
Parenta8b5c3c03b37ebf90e7ee8c9cb7c8f913f50c79a (diff)
[hooks] Reworked all hooks to use awk for their logic
1 files changed, 18 insertions, 0 deletions
-rw-r--r--generate-hooks/create-description.awk18
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
+}