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
This commit is contained in:
Russell Keith-Magee 2007-03-20 11:07:52 +00:00
parent 83bed03a59
commit b8eec54041
2 changed files with 7 additions and 1 deletions

View File

@ -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

View File

@ -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 '