1
0
mirror of https://github.com/django/django.git synced 2025-07-03 17:29:12 +00:00

unicode: Changed the markup filters to use force_unicode() instead of

smart_unicode(), merely for consistency with the recommendations in the
documentation.


git-svn-id: http://code.djangoproject.com/svn/django/branches/unicode@5341 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Malcolm Tredinnick 2007-05-25 09:30:43 +00:00
parent c98f0b14c4
commit 29d2094b29

View File

@ -16,7 +16,7 @@ silently fail and return the un-marked-up text.
from django import template
from django.conf import settings
from django.utils.encoding import smart_str, smart_unicode
from django.utils.encoding import smart_str, force_unicode
register = template.Library()
@ -26,9 +26,9 @@ def textile(value):
except ImportError:
if settings.DEBUG:
raise template.TemplateSyntaxError, "Error in {% textile %} filter: The Python textile library isn't installed."
return smart_unicode(value)
return force_unicode(value)
else:
return smart_unicode(textile.textile(smart_str(value), encoding='utf-8', output='utf-8'))
return force_unicode(textile.textile(smart_str(value), encoding='utf-8', output='utf-8'))
def markdown(value):
try:
@ -36,9 +36,9 @@ def markdown(value):
except ImportError:
if settings.DEBUG:
raise template.TemplateSyntaxError, "Error in {% markdown %} filter: The Python markdown library isn't installed."
return smart_unicode(value)
return force_unicode(value)
else:
return smart_unicode(markdown.markdown(smart_str(value)))
return force_unicode(markdown.markdown(smart_str(value)))
def restructuredtext(value):
try:
@ -46,11 +46,11 @@ def restructuredtext(value):
except ImportError:
if settings.DEBUG:
raise template.TemplateSyntaxError, "Error in {% restructuredtext %} filter: The Python docutils library isn't installed."
return smart_unicode(value)
return force_unicode(value)
else:
docutils_settings = getattr(settings, "RESTRUCTUREDTEXT_FILTER_SETTINGS", {})
parts = publish_parts(source=smart_str(value), writer_name="html4css1", settings_overrides=docutils_settings)
return smart_unicode(parts["fragment"])
return force_unicode(parts["fragment"])
register.filter(textile)
register.filter(markdown)