Opened 13 years ago
Closed 12 years ago
#17576 closed Bug (wontfix)
Enclosing quotation marks for urlize. (Or make urlize easier to override)
Reported by: | Tom Christie | Owned by: | Tom Christie |
---|---|---|---|
Component: | Utilities | Version: | 1.3 |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Accepted | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
urlize currently allows enclosing brackets. It'd be good if it also allowed enclosing quotation marks. (eg. when calling urlize on JSON output.)
Two possible options:
- Add single and double quote pairs to
WRAPPING_PUNCTUATION
at https://github.com/django/django/blob/master/django/utils/html.py#L15 - Add wrapping_punctation=WRAPPING_PUNCTUATION, trailing_punctuation=TRAILING_PUNCTUATiON arguments to
urlize
to make it possible to override the defaults.
I think either would be reasonable, and both trivial changes.
Attachments (1)
Change History (4)
comment:1 by , 13 years ago
Triage Stage: | Unreviewed → Accepted |
---|
comment:2 by , 12 years ago
Component: | Template system → Utilities |
---|
The real question here is -- who's going to consider this change a regression?
comment:3 by , 12 years ago
Resolution: | → wontfix |
---|---|
Status: | new → closed |
I implemented option 1, but it doesn't work well on JSON. I'm attaching a patch with a failing test.
The problem is that, in addition to the closing quotation mark, there's usually a comma or a closing bracket, and it isn't be stripped. Clearly urlize isn't designed to handle JSON, and the change doesn't turn out to be trivial.
by , 12 years ago
Attachment: | 17576.patch added |
---|
+0 for option 1.
-1 for option 2, as it would be quite ugly to pass arguments to urlize in a template.
NB: technically, it's already possible to import WRAPPING_PUNCTUATION and TRAILING_PUNCTUATiON and mutate them — but of course they aren't a public API and may change any time, see r17362 for instance.