awesome-wm-widgets/_snippets/ellipsize.md

14 lines
237 B
Markdown
Raw Normal View History

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