Ticket #10931: 10931-3.diff

File 10931-3.diff, 1.4 KB (added by Claude Paroz, 13 years ago)

Updated to current trunk

  • django/utils/text.py

    diff --git a/django/utils/text.py b/django/utils/text.py
    index 14555dd..eaafb96 100644
    a b capfirst = lambda x: x and force_unicode(x)[0].upper() + force_unicode(x)[1:]  
    1818capfirst = allow_lazy(capfirst, unicode)
    1919
    2020# Set up regular expressions
    21 re_words = re.compile(r'&.*?;|<.*?>|(\w[\w-]*)', re.U)
    22 re_tag = re.compile(r'<(/)?([^ ]+?)(?: (/)| .*?)?>')
     21re_words = re.compile(r'&.*?;|<.*?>|(\w[\w-]*)', re.U|re.S)
     22re_tag = re.compile(r'<(/)?([^ ]+?)(?: (/)| .*?)?>', re.S)
    2323
    2424
    2525def wrap(text, width):
  • tests/regressiontests/utils/text.py

    diff --git a/tests/regressiontests/utils/text.py b/tests/regressiontests/utils/text.py
    index d4aa53f..aae7533 100644
    a b class TestUtilsText(unittest.TestCase):  
    6262            '</strong></p>', truncator.words(4, '....', html=True))
    6363        self.assertEqual(u'<p><strong><em>The quick brown fox</em></strong>'
    6464            '</p>', truncator.words(4, '', html=True))
     65        # Test with new line inside tag
     66        truncator = text.Truncator('<p>The quick <a href="xyz.html"\n'
     67            'id="mylink">brown fox</a> jumped over the lazy dog.</p>')
     68        self.assertEqual(u'<p>The quick <a href="xyz.html"\n'
     69            'id="mylink">brown...</a></p>', truncator.words(3, '...', html=True))
    6570
    6671    def test_old_truncate_words(self):
    6772        self.assertEqual(u'The quick brown fox jumped over the lazy dog.',
Back to Top