Show More
@@ -221,6 +221,13 b' def fill(text, width):' | |||||
221 | fp.write(rest) |
|
221 | fp.write(rest) | |
222 | return fp.getvalue() |
|
222 | return fp.getvalue() | |
223 |
|
223 | |||
|
224 | def firstline(text): | |||
|
225 | '''return the first line of text''' | |||
|
226 | try: | |||
|
227 | return text.splitlines(1)[0].rstrip('\r\n') | |||
|
228 | except IndexError: | |||
|
229 | return '' | |||
|
230 | ||||
224 | def isodate(date): |
|
231 | def isodate(date): | |
225 | '''turn a (timestamp, tzoff) tuple into an iso 8631 date and time.''' |
|
232 | '''turn a (timestamp, tzoff) tuple into an iso 8631 date and time.''' | |
226 | return util.datestr(date, format='%Y-%m-%d %H:%M') |
|
233 | return util.datestr(date, format='%Y-%m-%d %H:%M') | |
@@ -284,7 +291,7 b' common_filters = {' | |||||
284 | "escape": lambda x: cgi.escape(x, True), |
|
291 | "escape": lambda x: cgi.escape(x, True), | |
285 | "fill68": lambda x: fill(x, width=68), |
|
292 | "fill68": lambda x: fill(x, width=68), | |
286 | "fill76": lambda x: fill(x, width=76), |
|
293 | "fill76": lambda x: fill(x, width=76), | |
287 | "firstline": lambda x: x.splitlines(1)[0].rstrip('\r\n'), |
|
294 | "firstline": firstline, | |
288 | "tabindent": lambda x: indent(x, '\t'), |
|
295 | "tabindent": lambda x: indent(x, '\t'), | |
289 | "hgdate": hgdate, |
|
296 | "hgdate": hgdate, | |
290 | "isodate": isodate, |
|
297 | "isodate": isodate, |
General Comments 0
You need to be logged in to leave comments.
Login now