Message195065
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. |
|
Date |
User |
Action |
Args |
2013-08-13 10:12:58 | serhiy.storchaka | set | recipients:
+ serhiy.storchaka, barry, georg.brandl, pitrou, ezio.melotti, steven.daprano, r.david.murray, python-dev, vajrasky |
2013-08-13 10:12:58 | serhiy.storchaka | set | messageid: <1376388778.3.0.982069932509.issue18725@psf.upfronthosting.co.za> |
2013-08-13 10:12:58 | serhiy.storchaka | link | issue18725 messages |
2013-08-13 10:12:58 | serhiy.storchaka | create | |
|