Comments
Patch
@@ -685,6 +685,14 @@
return _correctauthorformat.match(author) is not None
+def firstline(text):
+ """Return the first line of the input"""
+ try:
+ return text.splitlines()[0]
+ except IndexError:
+ return b''
+
+
def ellipsis(text, maxlength=400):
"""Trim string to at most maxlength (default: 400) columns in display."""
return encoding.trim(text, maxlength, ellipsis=b'...')
@@ -268,10 +268,7 @@
@templatefilter(b'firstline', intype=bytes)
def firstline(text):
"""Any text. Returns the first line of text."""
- try:
- return text.splitlines()[0]
- except IndexError:
- return b''
+ return stringutil.firstline(text)
@templatefilter(b'hex', intype=bytes)