Opened 17 years ago
Closed 17 years ago
#4821 closed (wontfix)
Add hyphenation option to djago.utils.text.wrap and a default filter hyphenatedwordwrap
Reported by: | Owned by: | nobody | |
---|---|---|---|
Component: | Template system | Version: | dev |
Severity: | Keywords: | hyphenate wordwrap | |
Cc: | Triage Stage: | Design decision needed | |
Has patch: | yes | Needs documentation: | yes |
Needs tests: | yes | Patch needs improvement: | yes |
Easy pickings: | no | UI/UX: | no |
Description
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' >>>
Attachments (1)
Change History (5)
by , 17 years ago
Attachment: | hyphenate.diff added |
---|
comment:1 by , 17 years ago
Triage Stage: | Unreviewed → Design decision needed |
---|
I think that it's maybe a bit obscure for core (especially since it isn't internationalized), but we'll see.
comment:2 by , 17 years ago
I didn't notice the groups discussion which looks pretty positive. I'll leave as DDN for a core to promote, however.
comment:4 by , 17 years ago
Resolution: | → wontfix |
---|---|
Status: | new → closed |
Seems this would be a good addition to a third-party library, but I agree with Chris that it's a bit too obscure for Django core.
patch with hyphenate.py, utils.text and templates.defaultfilters changes