ubernostrum  committed 084156d

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

  • Participants
  • Parent commits 8942518
  • Branches default

Comments (0)

Files changed (1)

File template_utils/

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