SF #1149508: ensure textwrap handles hyphenated numbers correctly,

eg. "2004-03-04" is not broken across lines.  (Merged from 2.4 branch.)
This commit is contained in:
Greg Ward 2005-03-05 02:53:17 +00:00
parent 00a73e7715
commit 40407943b7
3 changed files with 26 additions and 3 deletions

View file

@ -78,9 +78,10 @@ class TextWrapper:
# splits into
# 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'(?<=[\w\!\"\'\&\.\,\?])-{2,}(?=\w))') # em-dash
wordsep_re = re.compile(
r'(\s+|' # any whitespace
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
# is US-ASCII only (and therefore English-only)