mirror of
https://github.com/python/cpython.git
synced 2025-12-31 04:23:37 +00:00
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:
parent
00a73e7715
commit
40407943b7
3 changed files with 26 additions and 3 deletions
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue