summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWill Thompson <will.thompson@collabora.co.uk>2009-11-30 11:16:20 (GMT)
committerWill Thompson <will.thompson@collabora.co.uk>2009-11-30 11:16:20 (GMT)
commit77b1c1ccca1cc0d9a7d1fe6c517059ed0c6cee1a (patch)
tree696c160a3c9b8c10ee42c15453b6a95bab4fc1c8
parent1b106cb067b82b88114572c60d09315982bd9aeb (diff)
downloadtacky-77b1c1ccca1cc0d9a7d1fe6c517059ed0c6cee1a.tar.gz
tacky-77b1c1ccca1cc0d9a7d1fe6c517059ed0c6cee1a.tar.xz
Don't treat the entire paste as one paragraph.
TextWrapper.fill() wraps a single paragraph, which leads to weirdness if you feed it several paragraphs. If the previous paragraph ended with a line of n characters, the first line of the next paragraph is wrapped after about 70 - n characters. This seems like a better approximation to what we want.
-rw-r--r--paste.py4
1 files changed, 3 insertions, 1 deletions
diff --git a/paste.py b/paste.py
index c3ecc5b..085a1ee 100644
--- a/paste.py
+++ b/paste.py
@@ -122,7 +122,9 @@ class PasteResource(resource.Resource):
if 'wrap' in request.args:
t = textwrap.TextWrapper()
t.replace_whitespace = False;
- self.text = t.fill(self.text)
+ self.text = '\n\n'.join([t.fill(para)
+ for para in self.text.split('\n\n')
+ ])
lexer = pygments.lexers.get_lexer_by_name(self.format)
formatter = pygments.formatters.HtmlFormatter(