diff --git a/django/utils/text.py b/django/utils/text.py index 14555ddd0e..eaafb96d7c 100644 --- a/django/utils/text.py +++ b/django/utils/text.py @@ -18,8 +18,8 @@ capfirst = lambda x: x and force_unicode(x)[0].upper() + force_unicode(x)[1:] capfirst = allow_lazy(capfirst, unicode) # Set up regular expressions -re_words = re.compile(r'&.*?;|<.*?>|(\w[\w-]*)', re.U) -re_tag = re.compile(r'<(/)?([^ ]+?)(?: (/)| .*?)?>') +re_words = re.compile(r'&.*?;|<.*?>|(\w[\w-]*)', re.U|re.S) +re_tag = re.compile(r'<(/)?([^ ]+?)(?: (/)| .*?)?>', re.S) def wrap(text, width): diff --git a/tests/regressiontests/utils/text.py b/tests/regressiontests/utils/text.py index d4aa53fba9..aae75339bc 100644 --- a/tests/regressiontests/utils/text.py +++ b/tests/regressiontests/utils/text.py @@ -62,6 +62,11 @@ class TestUtilsText(unittest.TestCase): '
', truncator.words(4, '....', html=True)) self.assertEqual(u'The quick brown fox' '
', truncator.words(4, '', html=True)) + # Test with new line inside tag + truncator = text.Truncator('The quick brown fox jumped over the lazy dog.
') + self.assertEqual(u'The quick brown...
', truncator.words(3, '...', html=True)) def test_old_truncate_words(self): self.assertEqual(u'The quick brown fox jumped over the lazy dog.',