utils.text_helpers

Truncation and safe excerpt rendering.

Functions

truncate(text[, max_len, suffix])

Truncate text to max_len characters, appending suffix if cut.

Module Contents

utils.text_helpers.truncate(text, max_len=600, suffix='…')[source]

Truncate text to max_len characters, appending suffix if cut.

@ In, text, str, the text to truncate (falsy input returns “”) @ In, max_len, int, maximum length of the returned string including suffix @ In, suffix, str, appended when the text is truncated @ Out, out, str, the (possibly truncated) string

Parameters:
  • text (str)

  • max_len (int)

  • suffix (str)

Return type:

str