def break_long_words(value, max_word_length=8):
 tagless = django.utils.html.strip_tags(value)
 re_capitalized_word = re.compile('([A-Z][a-z][a-z]+)', re.UNICODE)
 words = re_capitalized_word.split(tagless)
 re_too_many_letters_in_a_row = re.compile(('([\\w]{%d}|[.\\_^/])' % max_word_length), re.UNICODE)
 broken_words = []
 for word in words:
  if word:
   broken_words += re_too_many_letters_in_a_row.split(word)
 broken_words = filter((lambda x: x), broken_words)
 return u'\u200b'.join(broken_words)

def break_long_words ( value , max_word_length = 8 ) : tagless = django . utils . html . strip_tags ( value ) re_capitalized_word = re . compile ( '([A-Z][a-z][a-z]+)' , re . UNICODE ) words = re_capitalized_word . split ( tagless ) re_too_many_letters_in_a_row = re . compile ( ( '([\\w]{%d}|[.\\_^/])' % max_word_length ) , re . UNICODE ) broken_words = [ ] for word in words : if word : broken_words += re_too_many_letters_in_a_row . split ( word ) broken_words = filter ( ( lambda x : x ) , broken_words ) return u'\u200b' . join ( broken_words )
this filter does two things: * it removes all html tags from the input .