summaryrefslogtreecommitdiff
path: root/django/utils/text.py
diff options
context:
space:
mode:
authorArthur Koziel <arthur@arthurkoziel.com>2010-09-13 00:04:27 +0000
committerArthur Koziel <arthur@arthurkoziel.com>2010-09-13 00:04:27 +0000
commitdd49269c7db008b2567f50cb03c4d3d9b321daa1 (patch)
tree326dd25bb045ac016cda7966b43cbdfe1f67d699 /django/utils/text.py
parentc9b188c4ec939abbe48dae5a371276742e64b6b8 (diff)
downloaddjango-soc2010/app-loading.tar.gz
[soc2010/app-loading] merged trunkarchive/soc2010/app-loadingsoc2010/app-loading
git-svn-id: http://code.djangoproject.com/svn/django/branches/soc2010/app-loading@13818 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django/utils/text.py')
-rw-r--r--django/utils/text.py12
1 files changed, 9 insertions, 3 deletions
diff --git a/django/utils/text.py b/django/utils/text.py
index 5d633b7afe..b05460486d 100644
--- a/django/utils/text.py
+++ b/django/utils/text.py
@@ -39,7 +39,10 @@ wrap = allow_lazy(wrap, unicode)
def truncate_words(s, num, end_text='...'):
"""Truncates a string after a certain number of words. Takes an optional
argument of what should be used to notify that the string has been
- truncated, defaults to ellipsis (...)"""
+ truncated, defaulting to ellipsis (...)
+
+ Newlines in the string will be stripped.
+ """
s = force_unicode(s)
length = int(num)
words = s.split()
@@ -51,10 +54,13 @@ def truncate_words(s, num, end_text='...'):
truncate_words = allow_lazy(truncate_words, unicode)
def truncate_html_words(s, num, end_text='...'):
- """Truncates html to a certain number of words (not counting tags and
+ """Truncates HTML to a certain number of words (not counting tags and
comments). Closes opened tags if they were correctly closed in the given
html. Takes an optional argument of what should be used to notify that the
- string has been truncated, defaults to ellipsis (...)."""
+ string has been truncated, defaulting to ellipsis (...).
+
+ Newlines in the HTML are preserved.
+ """
s = force_unicode(s)
length = int(num)
if length <= 0: