Anonymous avatar Anonymous committed 084156d

Make Textile filter work again now that Django's Unicode branch has merged.

Comments (0)

Files changed (1)

template_utils/markup.py

 def textile(text, **kwargs):
     """
     Applies Textile conversion to a string, and returns the HTML.
+
+    Note that PyTextile does not handle Unicode strings correctly, so
+    this filter uses Django's ``force_unicode`` and ``smart_str``
+    utilities to roundtrip to a utf-8 bytestring and back to Unicode
+    when needed.
+
+    If you're not using Django, you'll need to supply your own Textile
+    filter with any necessary workarounds for Unicode strings.
     
     """
+    from django.utils.encoding import smart_str, force_unicode
     import textile
-    return textile.textile(text, **kwargs)
+    return force_unicode(textile.textile(smart_str(text), encoding='utf-8', output='utf-8'))
 
 def markdown(text, **kwargs):
     """
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.