]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
SF #965425: fix wordsep_re so hyphenated words are handled correctly
authorGreg Ward <gward@python.net>
Thu, 3 Jun 2004 01:53:13 +0000 (01:53 +0000)
committerGreg Ward <gward@python.net>
Thu, 3 Jun 2004 01:53:13 +0000 (01:53 +0000)
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

index d9df01928c61dbc77bacfc1dc960a5233d1b3b90..32ab10bfbacd71573ead7cd0c330a9ecd66dabfc 100644 (file)
@@ -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