Opened 17 years ago
Closed 12 years ago
#6526 closed New feature (wontfix)
Add remove/escape/replace functions to markdown filter
Reported by: | Eric Abrahamsen | Owned by: | thomaspurchas |
---|---|---|---|
Component: | contrib.markup | Version: | dev |
Severity: | Normal | Keywords: | markup markdown |
Cc: | girzel@…, d1b, thomaspurchas | Triage Stage: | Accepted |
Has patch: | yes | Needs documentation: | yes |
Needs tests: | yes | Patch needs improvement: | yes |
Easy pickings: | no | UI/UX: | no |
Description
Markdown.py supports a variety of safe_modes, allowing users to replace HTML, escape it, or remove it cleanly. Django's markdown template filter currently doesn't support anything but replacement with a string. This patch to the markdown() function in django.contrib.markup.templatetags provides that ability, allowing users to pass "safe","remove","escape" or "replace" as the first argument in the extension list. Backwards compatibility is maintained.
Improvements to the patch are welcome...
Attachments (5)
Change History (22)
by , 17 years ago
comment:1 by , 17 years ago
Cc: | added |
---|
comment:2 by , 17 years ago
Triage Stage: | Unreviewed → Someday/Maybe |
---|
I think this is a good snippet. But it is not important to have it in the django source. (my opinion)
comment:3 by , 17 years ago
Resolution: | → invalid |
---|---|
Status: | new → closed |
Django's Markdown filter already allows you to use any Markdown extensions you have installed, including safe mode.
comment:4 by , 16 years ago
Resolution: | invalid |
---|---|
Status: | closed → reopened |
In fact, we can use extensions but not passing options to safe_mode extension which are : 'remove
', 'escape
', 'replace
' (see http://www.freewisdom.org/projects/python-markdown/Using_as_a_Module).
At least, it could be great to be able to change markdown.HTML_REMOVED_TEXT
cleanup within Django settings.
by , 16 years ago
Attachment: | 6526-mardown-html-removed-text.diff added |
---|
Adding settings to customize markdown remove text
by , 16 years ago
Attachment: | 6526-mardown-with-options-for-safe-mode.diff added |
---|
Markdown filter accepting options for safe_mode
by , 16 years ago
Attachment: | 6526-markdown-with-options-for-safe-mode.diff added |
---|
comment:6 by , 14 years ago
This ticket has been sitting around for 2 years. Any chance we can see it implemented?
It is a simple, straightforward fix that works and does not cause any backward-incompatible changes. It enables the use of Markdown's VERY useful HTML replacing, which many (including me) need in our projects.
Is there a reason it hasn't been implemented? If not, when could we expect it integrated?
Who can I bribe with a beer to get this thing put into core?
follow-up: 16 comment:7 by , 14 years ago
milestone: | → 1.4 |
---|---|
Needs documentation: | set |
Needs tests: | set |
Patch needs improvement: | set |
Triage Stage: | Someday/Maybe → Accepted |
- The patch needs unittests to show that it works correctly.
- It needs documentation. Current docs for
markup
are not very user friendly, but at least the doc string gives you some clue how to use it. Updating the docstring is a minimum. Write proper docs for those template tags for bonus points :) - It needs some more work. My biggest annoyance is
markdown.HTML_REMOVED_TEXT
- I could live with it's content if it was translatable, but changing it to something more human-friendly is desirable. Also, while there probably are no extensions called "remove", "escape" and "replace" the names are a bit confusing. I propose using something like{{ text|markdown:"safe=replace,more_extensions" }}
instead.
comment:8 by , 14 years ago
Component: | Contrib apps → contrib.markup |
---|
comment:9 by , 14 years ago
Type: | → New feature |
---|
comment:10 by , 14 years ago
Cc: | added |
---|---|
Severity: | → Normal |
comment:13 by , 12 years ago
Owner: | changed from | to
---|---|
Status: | reopened → new |
comment:14 by , 12 years ago
Status: | new → assigned |
---|
comment:15 by , 12 years ago
Cc: | added |
---|
comment:16 by , 12 years ago
Replying to lrekucki:
- The patch needs unittests to show that it works correctly.
- It needs documentation. Current docs for
markup
are not very user friendly, but at least the doc string gives you some clue how to use it. Updating the docstring is a minimum. Write proper docs for those template tags for bonus points :)- It needs some more work. My biggest annoyance is
markdown.HTML_REMOVED_TEXT
- I could live with it's content if it was translatable, but changing it to something more human-friendly is desirable. Also, while there probably are no extensions called "remove", "escape" and "replace" the names are a bit confusing. I propose using something like{{ text|markdown:"safe=replace,more_extensions" }}
instead.
lrekucki I have implemented the safe mode setting using {{ text|markdown:"safe=replace,more_extensions" }}
as you suggested, the attached patch also includes some new tests as well.
Also if you can still remember could you clarify what you mean by:
My biggest annoyance is
markdown.HTML_REMOVED_TEXT
- I could live with it's content if it was translatable, but changing it to something more human-friendly is desirable.
comment:17 by , 12 years ago
Resolution: | → wontfix |
---|---|
Status: | assigned → closed |
contrib.markup has been deprecated (#18504) and will be removed in Django 1.6. We won't add any new feature to it, and we encourage users to create external apps or contribute to an existing one. Closing as obsolete.
new version of the markup filter