New helper function: crop_text
This commit is contained in:
parent
1a0da5a633
commit
d381768c8f
1 changed files with 14 additions and 0 deletions
|
|
@ -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…
Add table
Add a link
Reference in a new issue