[Python-bugs-list] [ python-Bugs-596434 ] textwrap has problems wrapping hyphens

noreply@sourceforge.net noreply@sourceforge.net
Wed, 11 Sep 2002 19:06:26 -0700


Bugs item #596434, was opened at 2002-08-17 10:46
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=596434&group_id=5470

Category: Python Library
Group: Python 2.3
Status: Open
Resolution: Fixed
Priority: 5
Submitted By: David Goodger (goodger)
Assigned to: Greg Ward (gward)
Summary: textwrap has problems wrapping hyphens

Initial Comment:
(Greg already knows about this from private mail; 
this makes it "official".)

Long multi-word command-line options (begin 
with "--" and contain internal "-") inside text may be 
wrapped badly by textwrap.  For example, "--an-
option" may become "--\nan-option" or "--an-\
noption".  Perhaps words that begin with hyphens 
should not be wrapped at all?

----------------------------------------------------------------------

>Comment By: David Goodger (goodger)
Date: 2002-09-11 22:06

Message:
Logged In: YES 
user_id=7733

More edge cases came up today.  These break at the 
slashes:

    "(--option)" --> "(/--/option)"

    "(--option-opt)" --> "(/--option-/opt)"

All but the last of these breaks are bad.

Perhaps TextWrapper should have a 
"break_whitespace_only" option?  This would be 
especially useful for technical text, where breaks at 
hyphens may change the text's meaning.

----------------------------------------------------------------------

Comment By: David Goodger (goodger)
Date: 2002-08-25 10:29

Message:
Logged In: YES 
user_id=7733

There's still an edge case that gives poor results.  Try 
wrapping "--text--.".  It will wrap like "--text/--/.", leaving 
just the period (".") or the dashes & period ("--.") on the 
next line.  The latter may or may not be a problem, but 
I'd say wrapping just the sentence-ending period 
definitely *is* a problem.

A more plausible example is "what the--.".

----------------------------------------------------------------------

Comment By: Greg Ward (gward)
Date: 2002-08-22 17:04

Message:
Logged In: YES 
user_id=14422

Thanks for the reminder, David!

Fixed in Lib/textwrap.py rev 1.14.


----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=596434&group_id=5470