Truncate Text In Lektor
In this example, variable post is an instance of Markdown.
Snippet was tested with Jinja3 template engine.
I use it for generating my blog entry previews.
{{ post.body.html | striptags | truncate(length=200, killwords=False, end='...') }}
post.body.html: is the Lektor object containing regular string or HTML text.striptags: Removes all HTML markup and returns pure text. docstruncate(length=200, killwords=False, end='...'): truncate text to 200 symbols, stop at the nearest word that fits this length, and add “…” in the end of the truncated string. docs
