Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

unicode: Fixed #4662 -- Fixed a remaining ASCII assumption in

truncatewords_html(). Thanks, Ivan Sagalaev.


git-svn-id: http://code.djangoproject.com/svn/django/branches/unicode@5533 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit daaa3a1dde1d400d57206b258ae62282521461c3 1 parent 9c59947
Malcolm Tredinnick authored June 25, 2007
2  django/utils/text.py
@@ -59,7 +59,7 @@ def truncate_html_words(s, num):
59 59
         return u''
60 60
     html4_singlets = ('br', 'col', 'link', 'base', 'img', 'param', 'area', 'hr', 'input')
61 61
     # Set up regular expressions
62  
-    re_words = re.compile(r'&.*?;|<.*?>|([A-Za-z0-9][\w-]*)')
  62
+    re_words = re.compile(r'&.*?;|<.*?>|(\w[\w-]*)', re.U)
63 63
     re_tag = re.compile(r'<(/)?([^ ]+?)(?: (/)| .*?)?>')
64 64
     # Count non-HTML words and keep note of open tags
65 65
     pos = 0
3  tests/regressiontests/defaultfilters/tests.py
@@ -104,6 +104,9 @@
104 104
 >>> truncatewords_html(u'<p>one <a href="#">two - three <br>four</a> five</p>', 100)
105 105
 u'<p>one <a href="#">two - three <br>four</a> five</p>'
106 106
 
  107
+>>> truncatewords_html(u'\xc5ngstr\xf6m was here', 1)
  108
+u'\xc5ngstr\xf6m ...'
  109
+
107 110
 >>> upper(u'Mixed case input')
108 111
 u'MIXED CASE INPUT'
109 112
 

0 notes on commit daaa3a1

Please sign in to comment.
Something went wrong with that request. Please try again.