Add hyphenation option to djago.utils.text.wrap and a default filter hyphenatedwordwrap
|Reported by:||django@…||Owned by:||nobody|
|Cc:||Triage Stage:||Design decision needed|
|Has patch:||yes||Needs documentation:||yes|
|Needs tests:||yes||Patch needs improvement:||yes|
Ned Batchelder recently released an implementation of Frank Liang's hyphenation algorithm for python into the public domain.
This patch includes this file as django.utils.hyphenate and adds an optional argument keyword argument 'hyphenate' to django.utils.text.wrap to do the obvious. It defaults to False. A new default filter is added hyphenatedwordwrap which does the obvious as well.
There are internationalization issues which still need to be worked out, documentation and a unit test to be added as well.
I may not be able to work on the internationalization part so I am posting the patch as I have it working now.
>>> from django.utils.text import * >>> wrap("this is a test of the word wrap system with hyphenation", 10) u'this is a\ntest of\nthe word\nwrap\nsystem\nwith\nhyphenation' >>> wrap("this is a test of the word wrap system with hyphenation", 10, True) u'this is a\ntest of\nthe word\nwrap sys-\ntem with hy-\nphenation' >>> wrap("this is a test of the word wrap\nsystem with hyphenation", 10, True) u'this is a\ntest of\nthe word\nwrap\nsystem\nwith hy-\nphenation' >>>
Change History (5)
Changed 9 years ago by django@…
comment:1 Changed 9 years ago by SmileyChris
- Triage Stage changed from Unreviewed to Design decision needed