awesome-wm-widgets/_snippets/ellipsize.md

15 lines
247 B
Markdown
Raw Normal View History

2020-11-15 03:26:34 +01:00
---
layout: page
---
# Ellipsize
2020-12-18 02:29:06 +01:00
>Ellipsizes string to a given length
{:.filename}
2020-11-15 03:26:34 +01:00
```lua
local function ellipsize(text, length)
return (text:len() > length and length > 0)
and text:sub(0, length - 3) .. '...'
or text
end
```