Show More
@@ -268,10 +268,7 b' def fill76(text):' | |||||
268 | @templatefilter(b'firstline', intype=bytes) |
|
268 | @templatefilter(b'firstline', intype=bytes) | |
269 | def firstline(text): |
|
269 | def firstline(text): | |
270 | """Any text. Returns the first line of text.""" |
|
270 | """Any text. Returns the first line of text.""" | |
271 | try: |
|
271 | return stringutil.firstline(text) | |
272 | return text.splitlines()[0] |
|
|||
273 | except IndexError: |
|
|||
274 | return b'' |
|
|||
275 |
|
272 | |||
276 |
|
273 | |||
277 | @templatefilter(b'hex', intype=bytes) |
|
274 | @templatefilter(b'hex', intype=bytes) |
@@ -685,6 +685,14 b' def isauthorwellformed(author):' | |||||
685 | return _correctauthorformat.match(author) is not None |
|
685 | return _correctauthorformat.match(author) is not None | |
686 |
|
686 | |||
687 |
|
687 | |||
|
688 | def firstline(text): | |||
|
689 | """Return the first line of the input""" | |||
|
690 | try: | |||
|
691 | return text.splitlines()[0] | |||
|
692 | except IndexError: | |||
|
693 | return b'' | |||
|
694 | ||||
|
695 | ||||
688 | def ellipsis(text, maxlength=400): |
|
696 | def ellipsis(text, maxlength=400): | |
689 | """Trim string to at most maxlength (default: 400) columns in display.""" |
|
697 | """Trim string to at most maxlength (default: 400) columns in display.""" | |
690 | return encoding.trim(text, maxlength, ellipsis=b'...') |
|
698 | return encoding.trim(text, maxlength, ellipsis=b'...') |
General Comments 0
You need to be logged in to leave comments.
Login now