Message47844
The following patch makes textwrap not consider strings
of numbers with dashes to be wrappable hyphenated words.
For example, this code:
print textwrap.fill('aaaaaaaaaa 2005-02-21', 18)
previously produces:
aaaaaaaaaa 2005-
02-21
but with patch:
aaaaaaaaaa
2005-02-21
--- /usr/lib/python2.4/textwrap.py 2005-02-09
04:02:11.000000000 -0800
+++ /tmp/textwrap.py 2005-02-22 17:07:19.000000000 -0800
@@ -79,7 +79,7 @@
# Hello/ /there/ /--/ /you/ /goof-/ball,/ /use/
/the/ /-b/ /option!
# (after stripping out empty strings).
wordsep_re = re.compile(r'(\s+|'
# any whitespace
-
r'[^\s\w]*\w{2,}-(?=\w{2,})|' # hyphenated words
+
r'[^\s\w]*\w+[a-zA-Z]-(?=\w+[a-zA-Z])|' # hyphenated words
r'(?<=[\w\!\"\'\&\.\,\?])-{2,}(?=\w))') # em-dash
# XXX this is not locale- or charset-aware --
string.lowercase
|
|
Date |
User |
Action |
Args |
2007-08-23 15:41:58 | admin | link | issue1149508 messages |
2007-08-23 15:41:58 | admin | create | |
|