diff options
| author | ianb <devnull@localhost> | 2005-05-04 17:06:43 +0000 |
|---|---|---|
| committer | ianb <devnull@localhost> | 2005-05-04 17:06:43 +0000 |
| commit | d54b2b7cf7b31a23d55466fd2fcfe1ef6f9d512d (patch) | |
| tree | 6b4c9b039cc41f10606aede977c73e46c0a5bb78 /paste/exceptions | |
| parent | f612714dcf1dcada56674684642eaaac70469f99 (diff) | |
| download | paste-d54b2b7cf7b31a23d55466fd2fcfe1ef6f9d512d.tar.gz | |
Fixed word wrapping some
Diffstat (limited to 'paste/exceptions')
| -rw-r--r-- | paste/exceptions/formatter.py | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/paste/exceptions/formatter.py b/paste/exceptions/formatter.py index b59cbe8..bf8e1fb 100644 --- a/paste/exceptions/formatter.py +++ b/paste/exceptions/formatter.py @@ -231,18 +231,24 @@ class HTMLFormatter(TextFormatter): table.append('</table>') return '\n'.join(table) - def make_wrappable(self, html, wrap_limit=50, + def make_wrappable(self, html, wrap_limit=60, split_on=';?&@!$#-/\\"\''): # Currently using <wbr>, maybe should use ​ # http://www.cs.tut.fi/~jkorpela/html/nobr.html words = html.split() new_words = [] for word in words: - for char in split_on: - if char in word: - word = word.replace(char, char+'<wbr>') - break - new_words.append(word) + if len(word) > wrap_limit: + for char in split_on: + if char in word: + words = [ + self.make_wrappable(w, wrap_limit=wrap_limit, + split_on=split_on) + for w in word.split(char, 1)] + new_words.append('<wbr>'.join(words)) + break + else: + new_words.append(word) return ' '.join(new_words) hide_display_js = '''\ |
