Mercurial > public > mercurial-scm > hg
diff mercurial/templatefilters.py @ 19228:889807c79384
templater: add indentation arguments to the fill function
author | Sean Farley <sean.michael.farley@gmail.com> |
---|---|
date | Thu, 18 Apr 2013 15:48:22 -0500 |
parents | 8eef5b93db9d |
children | 1afe5d3939db |
line wrap: on
line diff
--- a/mercurial/templatefilters.py Wed Apr 10 18:56:38 2013 -0500 +++ b/mercurial/templatefilters.py Thu Apr 18 15:48:22 2013 -0500 @@ -99,8 +99,8 @@ para_re = None space_re = None -def fill(text, width): - '''fill many paragraphs.''' +def fill(text, width, initindent = '', hangindent = ''): + '''fill many paragraphs with optional indentation.''' global para_re, space_re if para_re is None: para_re = re.compile('(\n\n|\n\\s*[-*]\\s*)', re.M) @@ -121,7 +121,8 @@ yield text[start:m.start(0)], m.group(1) start = m.end(1) - return "".join([space_re.sub(' ', util.wrap(para, width=width)) + rest + return "".join([util.wrap(space_re.sub(' ', util.wrap(para, width)), + width, initindent, hangindent) + rest for para, rest in findparas()]) def fill68(text):