Code

Opened 7 years ago

Closed 6 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: master
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: UI/UX:

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@… 7 years ago.
patch with hyphenate.py, utils.text and templates.defaultfilters changes

Download all attachments as: .zip

Change History (5)

Changed 7 years ago by django@…

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

comment:1 Changed 7 years ago by SmileyChris

  • Triage Stage changed from Unreviewed to 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 Changed 7 years ago by SmileyChris

I didn't notice the groups discussion which looks pretty positive. I'll leave as DDN for a core to promote, however.

comment:3 Changed 7 years ago by cziken

It would be helpful!

comment:4 Changed 6 years ago by jacob

  • Resolution set to wontfix
  • Status changed from new to 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.

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.