New helper function: crop_text
This commit is contained in:
parent
5eee46892e
commit
41940806db
@ -94,6 +94,20 @@ BEGIN {
|
||||
'
|
||||
}
|
||||
|
||||
fn crop_text {
|
||||
max_chars = $0
|
||||
awk -v max'='^$max_chars^' ' '
|
||||
{
|
||||
nc += 1 + length;
|
||||
if(nc > max) {
|
||||
print substr($0, 1, nc - max) "..."
|
||||
exit
|
||||
}
|
||||
print
|
||||
}'
|
||||
}
|
||||
|
||||
|
||||
# Cookies
|
||||
fn set_cookie {
|
||||
# TODO: should check input values more carefully
|
||||
|
Loading…
Reference in New Issue
Block a user