From 5bb405002d9c88be8d2110b2fda5b23bad7dc3b8 Mon Sep 17 00:00:00 2001 From: Greg Ward Date: Thu, 3 Jun 2004 01:53:13 +0000 Subject: [PATCH] SF #965425: fix wordsep_re so hyphenated words are handled correctly when preceded by any punctuation, not just a sequence of more hyphens. (That was a special case so Optik and Docutils could wrap long options like --foo-bar correctly; this change generalizes the special-case.) Comment fix. --- Lib/textwrap.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Lib/textwrap.py b/Lib/textwrap.py index d9df01928c61..32ab10bfbacd 100644 --- a/Lib/textwrap.py +++ b/Lib/textwrap.py @@ -79,11 +79,11 @@ class TextWrapper: # Hello/ /there/ /--/ /you/ /goof-/ball,/ /use/ /the/ /-b/ /option! # (after stripping out empty strings). wordsep_re = re.compile(r'(\s+|' # any whitespace - r'-*\w{2,}-(?=\w{2,})|' # hyphenated words + r'[^\s\w]*\w{2,}-(?=\w{2,})|' # hyphenated words r'(?<=[\w\!\"\'\&\.\,\?])-{2,}(?=\w))') # em-dash - # XXX will there be a locale-or-charset-aware version of - # string.lowercase in 2.3? + # XXX this is not locale- or charset-aware -- string.lowercase + # is US-ASCII only (and therefore English-only) sentence_end_re = re.compile(r'[%s]' # lowercase letter r'[\.\!\?]' # sentence-ending punct. r'[\"\']?' # optional end-of-quote -- 2.47.3