Loading django/utils/text.py +2 −2 Original line number Diff line number Diff line Loading @@ -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): Loading tests/regressiontests/utils/text.py +5 −0 Original line number Diff line number Diff line Loading @@ -62,6 +62,11 @@ class TestUtilsText(unittest.TestCase): '</strong></p>', truncator.words(4, '....', html=True)) self.assertEqual(u'<p><strong><em>The quick brown fox</em></strong>' '</p>', truncator.words(4, '', html=True)) # Test with new line inside tag truncator = text.Truncator('<p>The quick <a href="xyz.html"\n' 'id="mylink">brown fox</a> jumped over the lazy dog.</p>') self.assertEqual(u'<p>The quick <a href="xyz.html"\n' 'id="mylink">brown...</a></p>', truncator.words(3, '...', html=True)) def test_old_truncate_words(self): self.assertEqual(u'The quick brown fox jumped over the lazy dog.', Loading Loading
django/utils/text.py +2 −2 Original line number Diff line number Diff line Loading @@ -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): Loading
tests/regressiontests/utils/text.py +5 −0 Original line number Diff line number Diff line Loading @@ -62,6 +62,11 @@ class TestUtilsText(unittest.TestCase): '</strong></p>', truncator.words(4, '....', html=True)) self.assertEqual(u'<p><strong><em>The quick brown fox</em></strong>' '</p>', truncator.words(4, '', html=True)) # Test with new line inside tag truncator = text.Truncator('<p>The quick <a href="xyz.html"\n' 'id="mylink">brown fox</a> jumped over the lazy dog.</p>') self.assertEqual(u'<p>The quick <a href="xyz.html"\n' 'id="mylink">brown...</a></p>', truncator.words(3, '...', html=True)) def test_old_truncate_words(self): self.assertEqual(u'The quick brown fox jumped over the lazy dog.', Loading