blob: d82c65824bf6528b662e1c36d56f20c6c6231a69 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
(fn split [string]
(accumulate [res [] v _
(string:gmatch "%S+")]
(do
(table.insert res v)
res)))
(fn ends-with [string end]
(= (string.sub string (- (# end))) end))
(fn trim [str]
(str:match "^%s*(.-)%s*$"))
(fn truncate [str len ellipsis]
(if (and (= (type str) "string")
(< 0 (# str)))
(if (< (# str) len)
str
(.. (trim (luna.utf.sub str 1 len)) (or ellipsis "...")))
""))
{: split : ends-with : truncate}
|