Opened 17 years ago

Closed 16 years ago

#4821 closed (wontfix)

Add hyphenation option to djago.utils.text.wrap and a default filter hyphenatedwordwrap

Reported by: django@… 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)

hyphenate.diff (38.7 KB ) - added by django@… 17 years ago.
patch with hyphenate.py, utils.text and templates.defaultfilters changes

Download all attachments as: .zip

Change History (5)

by django@…, 17 years ago

Attachment: hyphenate.diff added

patch with hyphenate.py, utils.text and templates.defaultfilters changes

comment:1 by Chris Beaven, 17 years ago

Triage Stage: UnreviewedDesign 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 Chris Beaven, 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:3 by cziken, 17 years ago

It would be helpful!

comment:4 by Jacob, 16 years ago

Resolution: wontfix
Status: newclosed

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.

Note: See TracTickets for help on using tickets.
Back to Top