--
Ticket URL: <https://code.djangoproject.com/ticket/19496>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* needs_better_patch: => 0
* needs_docs: => 0
* easy: 0 => 1
* needs_tests: => 0
* stage: Unreviewed => Accepted
Comment:
Sure; we've added truncatedchars; makes sense that there would be a HTML-
sensitive equivalent.
--
Ticket URL: <https://code.djangoproject.com/ticket/19496#comment:1>
* owner: nobody => slurms
* status: new => assigned
* has_patch: 0 => 1
--
Ticket URL: <https://code.djangoproject.com/ticket/19496#comment:2>
Comment (by slurms):
Used truncatewords_html as a guideline, added docs & tests. All tests pass
under sqlite. Pull request here: https://github.com/django/django/pull/633
--
Ticket URL: <https://code.djangoproject.com/ticket/19496#comment:3>
* needs_better_patch: 0 => 1
Comment:
{{{
>>> truncatechars_html('<h1>test</h1>', 5)
u'<h1>t ...</h1>'
}}}
Should return u'<h1>te...</h1>'. Truncatewords adds an extra space in
front of the ellipsis but truncatechars doesn't.
--
Ticket URL: <https://code.djangoproject.com/ticket/19496#comment:4>
* owner: slurms => martmatwarne
--
Ticket URL: <https://code.djangoproject.com/ticket/19496#comment:5>
Comment (by martmatwarne):
The above issue should now be fixed. It also appears to have broken
truncatechars which I've now fixed
https://github.com/django/django/pull/1126
--
Ticket URL: <https://code.djangoproject.com/ticket/19496#comment:6>
Comment (by martmatwarne):
Actually there still appears to be issues when using html with only one
tag pair in it
--
Ticket URL: <https://code.djangoproject.com/ticket/19496#comment:7>
Comment (by EvilDMP):
I have marked this ticket as suitable for a first-time committer attending
a [https://dont-be-afraid-to-commit.readthedocs.org/ Don't be afraid to
commit workshop].
The next planned session will be hosted by
[http://www.cardiffdevworkshop.com Cardiff Dev Workshop] on Saturday 8th
June.
If you want to tackle this ticket before then, or at any time in fact,
please '''don't''' let the fact that it's assigned to me stop you. Feel
free to re-assign it to yourself and do whatever you like to it.
--
Ticket URL: <https://code.djangoproject.com/ticket/19496#comment:8>
* owner: martmatwarne => EvilDMP
--
Ticket URL: <https://code.djangoproject.com/ticket/19496#comment:9>
Comment (by saturn5971):
truncatechars_html was incorrectly adding the '...' to text that was under
the truncate length but only by 3 or fewer characters:
{{{
>>> truncatechars_html('abcd', 4)
u'a...'
}}}
I've provided an updated patch here, including an addition to the test:
[https://github.com/django/django/pull/1689]
--
Ticket URL: <https://code.djangoproject.com/ticket/19496#comment:10>
* version: 1.4 => master
* easy: 1 => 0
Comment:
I've left some comments on the PR for improvement.
--
Ticket URL: <https://code.djangoproject.com/ticket/19496#comment:11>
* cc: saturn5971 (added)
* keywords: truncatchars => truncatechars
Comment:
Thanks! I updated my pull request in accord with Timo's suggestions.
[https://github.com/django/django/pull/1689]
To eliminate redundant code between _html_chars and _html_words, I've
collapsed them into a single function, _truncate_html. I made the
requested documentation changes as well.
--
Ticket URL: <https://code.djangoproject.com/ticket/19496#comment:12>
* status: assigned => closed
* resolution: => fixed
Comment:
In [changeset:"f94f466cd3461527fb76a3e8951039a3c2388829"]:
{{{
#!CommitTicketReference repository=""
revision="f94f466cd3461527fb76a3e8951039a3c2388829"
Fixed #19496 -- Added truncatechars_html filter.
Thanks esevece for the suggestion and Nick Sandford and Martin Warne
for the inital work on the patch.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/19496#comment:13>