Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

textwrap has problems wrapping hyphens #37049

Closed
goodger opened this issue Aug 17, 2002 · 5 comments
Closed

textwrap has problems wrapping hyphens #37049

goodger opened this issue Aug 17, 2002 · 5 comments
Labels
stdlib Python modules in the Lib dir

Comments

@goodger
Copy link
Contributor

goodger commented Aug 17, 2002

BPO 596434
Nosy @goodger

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = None
closed_at = <Date 2003-05-07.01:21:42.000>
created_at = <Date 2002-08-17.14:46:32.000>
labels = ['library']
title = 'textwrap has problems wrapping hyphens'
updated_at = <Date 2003-05-07.01:21:42.000>
user = 'https://github.com/goodger'

bugs.python.org fields:

activity = <Date 2003-05-07.01:21:42.000>
actor = 'gward'
assignee = 'gward'
closed = True
closed_date = None
closer = None
components = ['Library (Lib)']
creation = <Date 2002-08-17.14:46:32.000>
creator = 'goodger'
dependencies = []
files = []
hgrepos = []
issue_num = 596434
keywords = []
message_count = 5.0
messages = ['12039', '12040', '12041', '12042', '12043']
nosy_count = 2.0
nosy_names = ['gward', 'goodger']
pr_nums = []
priority = 'normal'
resolution = 'fixed'
stage = None
status = 'closed'
superseder = None
type = None
url = 'https://bugs.python.org/issue596434'
versions = ['Python 2.3']

@goodger
Copy link
Contributor Author

goodger commented Aug 17, 2002

(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?

@goodger goodger closed this as completed Aug 17, 2002
@goodger goodger added the stdlib Python modules in the Lib dir label Aug 17, 2002
@goodger goodger closed this as completed Aug 17, 2002
@goodger goodger added the stdlib Python modules in the Lib dir label Aug 17, 2002
@gward
Copy link
Mannequin

gward mannequin commented Aug 22, 2002

Logged In: YES
user_id=14422

Thanks for the reminder, David!

Fixed in Lib/textwrap.py rev 1.14.

@goodger
Copy link
Contributor Author

goodger commented Aug 25, 2002

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--.".

@goodger
Copy link
Contributor Author

goodger commented Sep 12, 2002

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.

@gward
Copy link
Mannequin

gward mannequin commented May 7, 2003

Logged In: YES
user_id=14422

Finally! Fixed in rev 1.26 of Lib/textwrap.py, with tests
in rev 1.21 of Lib/test/test_textwrap.py.

@ezio-melotti ezio-melotti transferred this issue from another repository Apr 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stdlib Python modules in the Lib dir
Projects
None yet
Development

No branches or pull requests

1 participant