Opened 19 years ago

Last modified 18 years ago

#241 closed enhancement

Add a django.contrib.markup app — at Version 4

Reported by: django@… Owned by: Adrian Holovaty
Component: Core (Other) Version:
Severity: normal Keywords: textile filter template
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description (last modified by Adrian Holovaty)

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)

Change History (4)

comment:1 by django@…, 19 years ago

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!

comment:2 by Clint Ecker <clintecker@…>, 19 years ago

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 ;)

comment:3 by clintecker@…, 19 years ago

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/

comment:4 by Adrian Holovaty, 19 years ago

Description: modified (diff)
Summary: Addition of a Textile mark-up filterAdd a django.contrib.markup app
Note: See TracTickets for help on using tickets.
Back to Top