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.
Created on 2011年07月04日 02:13 by parent5446, last changed 2022年04月11日 14:57 by admin.
| Files | ||||
|---|---|---|---|---|
| File name | Uploaded | Description | Edit | |
| textwrap.py-beautiful-2011年07月11日_22-01-31_r71296+.diff | parent5446, 2011年07月12日 02:09 | Addition of beautiful algorithm to textwrap.py | ||
| Issue12485.v2.patch | gavanderlinden, 2015年04月14日 01:54 | Addition of beautiful algorithm to textwrap.py with tests | ||
| Messages (7) | |||
|---|---|---|---|
| msg139731 - (view) | Author: Tyler Romeo (parent5446) | Date: 2011年07月04日 02:12 | |
Python's textwrap module can be helpful at times, but personally I think there are a couple of things that could be added. First, when it comes to text wrapping, usually you're not dealing with a monospace font where each letter is the same size. If you're working with the Python Imaging Library for example, there is a function that you pass the text to in order to determine how wide (or tall) a font is. Therefore, it would be useful to have a parameter where the user can pass a function that gives a custom width for a set of text. The default for this parameter, of course, would be len. Also, this module uses a rough and efficient algorithm for wrapping text, but the results are not always aesthetically pleasing (one word hanging off on a line). Sometimes the user may want something that is wrapped more beautifully, so to say, such as is found in TeX. So there should also be a beautiful option that goes back and redistributes the text so that it is more aesthetically pleasing. This isn't exactly that important (minor improvements to a module that is probably not used much), but I figured I'd get it out there as I run into the problem all the time when trying to wrap text to be put in images of a set size. |
|||
| msg139785 - (view) | Author: Éric Araujo (eric.araujo) * (Python committer) | Date: 2011年07月04日 16:26 | |
Hi! Thanks for the report and patch. Are your two requests related? If not, it would be best to open two reports. |
|||
| msg139825 - (view) | Author: Tyler Romeo (parent5446) | Date: 2011年07月05日 02:40 | |
Nah, they're both unrelated. I'll separate the changes and remake the patches. (I'll keep this entry for the beautification part.) |
|||
| msg139827 - (view) | Author: Tyler Romeo (parent5446) | Date: 2011年07月05日 02:53 | |
OK, so here is the patch for just the new algorithm. |
|||
| msg139880 - (view) | Author: Éric Araujo (eric.araujo) * (Python committer) | Date: 2011年07月05日 15:42 | |
xrange does not exist in Python 3, it’s called range. You should have seen yesterday that I changed the versions: as a new feature, this cannot go into stable releases, only into the next one. I’m adding Georg to nosy per http://docs.python.org/devguide/experts |
|||
| msg140170 - (view) | Author: Tyler Romeo (parent5446) | Date: 2011年07月12日 02:09 | |
OK, sorry to get back so late, but here's the updated patch without xrange. I saw the version change but forgot that I used xrange in the function (old habits I guess). |
|||
| msg240827 - (view) | Author: Gijsbert Anthony van der Linden (gavanderlinden) * | Date: 2015年04月14日 01:54 | |
Updated the patch and added tests. Fixed a problem with the previous patch: result of map function was assumed to be list, however map in Python3 returns an interator. So I replaced it with a list comprehension. |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022年04月11日 14:57:19 | admin | set | github: 56694 |
| 2015年05月17日 21:58:40 | wiggin15 | set | nosy:
+ wiggin15 |
| 2015年04月14日 01:54:14 | gavanderlinden | set | files:
+ Issue12485.v2.patch versions: + Python 3.5, - Python 3.3 nosy: + gavanderlinden messages: + msg240827 |
| 2011年11月24日 17:17:49 | eric.araujo | set | stage: patch review -> test needed |
| 2011年07月12日 13:01:05 | r.david.murray | set | nosy:
+ r.david.murray |
| 2011年07月12日 02:09:45 | parent5446 | set | files: - textwrap.py-new-algorithm-2011年07月04日_22-45-53_r71219+.diff |
| 2011年07月12日 02:09:24 | parent5446 | set | files:
+ textwrap.py-beautiful-2011年07月11日_22-01-31_r71296+.diff messages: + msg140170 |
| 2011年07月05日 15:42:20 | eric.araujo | set | nosy:
+ georg.brandl messages: + msg139880 title: textwrap.wrap: add control for custom length and orphans -> textwrap.wrap: new argument for more pleasing output |
| 2011年07月05日 03:04:36 | parent5446 | set | files: - textwrap.py-improvement.diff |
| 2011年07月05日 02:53:23 | parent5446 | set | files:
+ textwrap.py-new-algorithm-2011年07月04日_22-45-53_r71219+.diff messages: + msg139827 |
| 2011年07月05日 02:40:05 | parent5446 | set | messages: + msg139825 |
| 2011年07月04日 16:26:57 | eric.araujo | set | title: Improvement of textwrap module -> textwrap.wrap: add control for custom length and orphans components: + Library (Lib), - Extension Modules keywords: + needs review nosy: + eric.araujo versions: + Python 3.3, - Python 2.7 messages: + msg139785 stage: patch review |
| 2011年07月04日 02:13:01 | parent5446 | create | |