equal
deleted
inserted
replaced
4 # |
4 # |
5 # This software may be used and distributed according to the terms of the |
5 # This software may be used and distributed according to the terms of the |
6 # GNU General Public License version 2 or any later version. |
6 # GNU General Public License version 2 or any later version. |
7 |
7 |
8 import cgi, re, os, time, urllib |
8 import cgi, re, os, time, urllib |
9 import encoding, node, util |
9 import encoding, node, util, error |
10 import hbisect |
10 import hbisect |
11 |
11 |
12 def addbreaks(text): |
12 def addbreaks(text): |
13 """:addbreaks: Any text. Add an XHTML "<br />" tag before the end of |
13 """:addbreaks: Any text. Add an XHTML "<br />" tag before the end of |
14 every line except the last. |
14 every line except the last. |
389 "user": userfilter, |
389 "user": userfilter, |
390 "emailuser": emailuser, |
390 "emailuser": emailuser, |
391 "xmlescape": xmlescape, |
391 "xmlescape": xmlescape, |
392 } |
392 } |
393 |
393 |
|
394 def fillfunc(context, mapping, args): |
|
395 if not (1 <= len(args) <= 2): |
|
396 raise error.ParseError(_("fill expects one or two arguments")) |
|
397 |
|
398 text = stringify(args[0][0](context, mapping, args[0][1])) |
|
399 width = 76 |
|
400 if len(args) == 2: |
|
401 try: |
|
402 width = int(stringify(args[1][0](context, mapping, args[1][1]))) |
|
403 except ValueError: |
|
404 raise error.ParseError(_("fill expects an integer width")) |
|
405 |
|
406 return fill(text, width) |
|
407 |
|
408 |
|
409 funcs = { |
|
410 "fill": fillfunc, |
|
411 } |
|
412 |
394 # tell hggettext to extract docstrings from these functions: |
413 # tell hggettext to extract docstrings from these functions: |
395 i18nfunctions = filters.values() |
414 i18nfunctions = filters.values() |