This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author serhiy.storchaka
Recipients barry, ezio.melotti, georg.brandl, pitrou, python-dev, r.david.murray, serhiy.storchaka, steven.daprano, vajrasky
Date 2013-08-13.10:12:58
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1376388778.3.0.982069932509.issue18725@psf.upfronthosting.co.za>
In-reply-to
Content
Functions in the textwrap module works with multiline text except a newly added (in issue18585) the shorten() function. Wrapping and shortening a multiline text using existing textwrap function is not a trivial job.

I propose to add two new parameters to the TextWrap class and wrap() and fill() functions: max_lines and placeholder. If the max_lines argument is specified then wrapped text truncated to max_lines and the last line shortened to the width argument.

>>>print(textwrap('Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.', width=40, max_lines=3))
Lorem ipsum dolor sit amet, consectetur
adipisicing elit, sed do eiusmod tempor
incididunt ut labore et dolore (...)

The shorten() function then will be just a particular case of fill() with max_lines=1.
History
Date User Action Args
2013-08-13 10:12:58serhiy.storchakasetrecipients: + serhiy.storchaka, barry, georg.brandl, pitrou, ezio.melotti, steven.daprano, r.david.murray, python-dev, vajrasky
2013-08-13 10:12:58serhiy.storchakasetmessageid: <1376388778.3.0.982069932509.issue18725@psf.upfronthosting.co.za>
2013-08-13 10:12:58serhiy.storchakalinkissue18725 messages
2013-08-13 10:12:58serhiy.storchakacreate