summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRussell Keith-Magee <russell@keith-magee.com>2007-03-20 11:07:52 +0000
committerRussell Keith-Magee <russell@keith-magee.com>2007-03-20 11:07:52 +0000
commitb8eec54041040eccbd4d6d1077257b65cdb85708 (patch)
tree7257360e3a2c8b9e316ad9ecc21e0f8ca06dc822
parent83bed03a5990ba90cd99c6b2ceedcaf3199626e2 (diff)
Fixed #3714 -- Fixed handling of indented text in wordwrap template filter. Thanks for the fix, Ian Clelland.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@4753 bcc190cf-cafb-0310-a4f2-bffc1f526a37
-rw-r--r--django/utils/text.py2
-rw-r--r--tests/regressiontests/defaultfilters/tests.py6
2 files changed, 7 insertions, 1 deletions
diff --git a/django/utils/text.py b/django/utils/text.py
index 1c1c456e2d..faf8705fa9 100644
--- a/django/utils/text.py
+++ b/django/utils/text.py
@@ -17,7 +17,7 @@ def wrap(text, width):
pos = len(word) - word.rfind('\n') - 1
for word in it:
if "\n" in word:
- lines = word.splitlines()
+ lines = word.split('\n')
else:
lines = (word,)
pos += len(lines[0]) + 1
diff --git a/tests/regressiontests/defaultfilters/tests.py b/tests/regressiontests/defaultfilters/tests.py
index c850806052..db3f7fab2a 100644
--- a/tests/regressiontests/defaultfilters/tests.py
+++ b/tests/regressiontests/defaultfilters/tests.py
@@ -133,6 +133,12 @@ u'\xcb'
>>> wordwrap('this is a long paragraph of text that really needs to be wrapped I\'m afraid', 14)
"this is a long\nparagraph of\ntext that\nreally needs\nto be wrapped\nI'm afraid"
+>>> wordwrap('this is a short paragraph of text.\n But this line should be indented',14)
+'this is a\nshort\nparagraph of\ntext.\n But this\nline should be\nindented'
+
+>>> wordwrap('this is a short paragraph of text.\n But this line should be indented',15)
+'this is a short\nparagraph of\ntext.\n But this line\nshould be\nindented'
+
>>> ljust('test', 10)
'test '