equal
deleted
inserted
replaced
3 # Copyright 2005, 2006 Matt Mackall <mpm@selenic.com> |
3 # Copyright 2005, 2006 Matt Mackall <mpm@selenic.com> |
4 # |
4 # |
5 # This software may be used and distributed according to the terms |
5 # This software may be used and distributed according to the terms |
6 # of the GNU General Public License, incorporated herein by reference. |
6 # of the GNU General Public License, incorporated herein by reference. |
7 |
7 |
8 import re |
|
9 from demandload import demandload |
8 from demandload import demandload |
10 from i18n import gettext as _ |
9 from i18n import gettext as _ |
11 from node import * |
10 from node import * |
12 demandload(globals(), "cStringIO cgi re sys os time urllib util textwrap") |
11 demandload(globals(), "cStringIO cgi re sys os time urllib util textwrap") |
13 |
12 |
192 else: |
191 else: |
193 cs.write(t) |
192 cs.write(t) |
194 walk(thing) |
193 walk(thing) |
195 return cs.getvalue() |
194 return cs.getvalue() |
196 |
195 |
197 para_re = re.compile('(\n\n|\n\\s*[-*]\\s*)', re.M) |
196 para_re = None |
198 space_re = re.compile(r' +') |
197 space_re = None |
199 |
198 |
200 def fill(text, width): |
199 def fill(text, width): |
201 '''fill many paragraphs.''' |
200 '''fill many paragraphs.''' |
|
201 global para_re, space_re |
|
202 if para_re is None: |
|
203 para_re = re.compile('(\n\n|\n\\s*[-*]\\s*)', re.M) |
|
204 space_re = re.compile(r' +') |
|
205 |
202 def findparas(): |
206 def findparas(): |
203 start = 0 |
207 start = 0 |
204 while True: |
208 while True: |
205 m = para_re.search(text, start) |
209 m = para_re.search(text, start) |
206 if not m: |
210 if not m: |