diff --git a/kallithea/lib/helpers.py b/kallithea/lib/helpers.py --- a/kallithea/lib/helpers.py +++ b/kallithea/lib/helpers.py @@ -101,8 +101,12 @@ def html_escape(s): .replace("'", "'") ) -def shorter(s, size=20): - postfix = '...' +def shorter(s, size=20, firstline=False, postfix='...'): + """Truncate s to size, including the postfix string if truncating. + If firstline, truncate at newline. + """ + if firstline: + s = s.split('\n', 1)[0].rstrip() if len(s) > size: return s[:size - len(postfix)] + postfix return s