Opened 6 years ago
Closed 6 years ago
#29798 closed Uncategorized (invalid)
truncatewords_html fails on some self-closing tags
Reported by: | Béranger Enselme | Owned by: | nobody |
---|---|---|---|
Component: | Template system | Version: | 2.1 |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
Also in 1.11...
>>> from django.template.defaultfilters import truncatewords_html >>> truncatewords_html('<p class="alinea">one two three</p>', 2) '<p class="alinea">one two ...</p>' >>> truncatewords_html('<p class="alinea">one two three</p><p class="alinea"/><p class="alinea">four five</p>', 4) '<p class="alinea">one two three</p><p class="alinea"/><p class="alinea">four ...</p></p>'
truncatewords_html
will add tag closures for every self-closing tag that has at least an attribute.
Note:
See TracTickets
for help on using tickets.
I think this is invalid. If I pump your HTML fragment into the W3 HTML Validator (as HTML 5) I get (amongst errors about the document structure not being right) this:
Looks like
truncatewords_html
's behaviour is correct.