Opened 10 years ago

Closed 10 years ago

Last modified 9 years ago

#241 closed enhancement (fixed)

Add a django.contrib.markup app

Reported by: django@… Owned by: jacob
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: UI/UX:

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:

---   (revision 356)
+++   (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 (6)

comment:1 Changed 10 years ago by django@…

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 Changed 10 years ago by Clint Ecker <clintecker@…>

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 Changed 10 years ago by clintecker@…

For people who want to play with this type of stuff: Markdown for Python:

Textile for python:

comment:4 Changed 10 years ago by adrian

  • Description modified (diff)
  • Summary changed from Addition of a Textile mark-up filter to Add a django.contrib.markup app

comment:5 Changed 10 years ago by jacob

  • Owner changed from adrian to jacob
  • Status changed from new to assigned

comment:6 Changed 10 years ago by jacob

  • Resolution set to fixed
  • Status changed from assigned to closed

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

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