Django

Code

Ticket #241 (closed: fixed)

Opened 3 years ago

Last modified 2 years ago

Add a django.contrib.markup app

Reported by: django@sharpbanana.co.uk Assigned to: jacob
Milestone: Component: Core framework
Version: Keywords: textile filter template
Cc: Triage Stage: Unreviewed
Has patch: 0 Needs documentation: 0
Needs tests: 0 Patch needs improvement: 0

Description (Last modified by adrian)

We should add a django.contrib.markup app, which would simply contain template tags to convert between markup languages such as Textile, Markdown, ReST, etc.

Here's a patch for a "textile" template filter:

Index: defaultfilters.py
===================================================================
--- defaultfilters.py   (revision 356)
+++ defaultfilters.py   (working copy)
@@ -416,6 +416,23 @@
     from pprint import pformat
     return pformat(value)

+def textile(value, _):
+    "Generates XHTML from Textile markup developed by Dean Allen"
+    try:
+        # Try and import textile
+        from textile import textile
+    except ImportError:
+        # No textile? Just return text again
+        return value
+
+    try:
+        value = textile(value)
+    except:
+        # Textile doesn't have a good system for rejecting bad input!
+        pass
+
+    return value
+
 # Syntax: template.register_filter(name of filter, callback, has_argument)
 template.register_filter('add', add, True)
 template.register_filter('addslashes', addslashes, False)
@@ -452,6 +469,7 @@
 template.register_filter('slugify', slugify, False)
 template.register_filter('stringformat', stringformat, True)
 template.register_filter('striptags', striptags, False)
+template.register_filter('textile', textile, False)
 template.register_filter('time', time, True)
 template.register_filter('timesince', timesince, False)
 template.register_filter('title', title, False)

Attachments

Change History

07/31/05 15:04:25 changed by django@sharpbanana.co.uk

Erm, sorry. It would have been better to submit the ticket and then attached the patch in a file.

I'll know for next time!

07/31/05 17:06:41 changed by Clint Ecker <clintecker@gmail.com>

I support this! It might be good to get Markdown support in here as well. I'm a huge Textile fan, just to disclose my intentions ;)

07/31/05 17:10:18 changed by clintecker@gmail.com

For people who want to play with this type of stuff: Markdown for Python: http://www.freewisdom.org/projects/python-markdown/

Textile for python: http://dealmeida.net/en/Projects/PyTextile/

08/02/05 13:29:07 changed by adrian

  • description changed.
  • summary changed from Addition of a Textile mark-up filter to Add a django.contrib.markup app.

08/08/05 12:59:01 changed by jacob

  • owner changed from adrian to jacob.
  • status changed from new to assigned.

08/10/05 13:31:34 changed by jacob

  • status changed from assigned to closed.
  • resolution set to fixed.

(In [467]) Fixed #241 -- added django.contrib.markup app with markup templatetags for Textile, ReST and Markdown


Add/Change #241 (Add a django.contrib.markup app)




Change Properties
Action