Opened 19 years ago

Last modified 18 years ago

#241 closed enhancement

Addition of a Textile mark-up filter — at Initial Version

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

It would be useful to be able to use textile as a filter for producing HTML from wiki style markup.

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 (0)

Note: See TracTickets for help on using tickets.
Back to Top