From 8453a1750f4ba2925bcccd775def0d8d255d6b99 Mon Sep 17 00:00:00 2001 From: Malcolm Tredinnick Date: Tue, 15 Apr 2008 02:00:15 +0000 Subject: [PATCH] Fixed #6387 -- Updated markdown filter to handle markdown-1.7 as well as earlier versions. Patch from cogg, jedie and Dmitri Fedortchenko. git-svn-id: http://code.djangoproject.com/svn/django/trunk@7423 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- django/contrib/markup/templatetags/markup.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/django/contrib/markup/templatetags/markup.py b/django/contrib/markup/templatetags/markup.py index 5d4f4786e1..982620bd08 100644 --- a/django/contrib/markup/templatetags/markup.py +++ b/django/contrib/markup/templatetags/markup.py @@ -65,7 +65,13 @@ def markdown(value, arg=''): safe_mode = True else: safe_mode = False - return mark_safe(force_unicode(markdown.markdown(smart_str(value), extensions, safe_mode=safe_mode))) + + # Unicode support only in markdown v1.7 or above. Version_info + # exist only in markdown v1.6.2rc-2 or above. + if getattr(markdown, "version_info", None) < (1,7): + return mark_safe(force_unicode(markdown.markdown(smart_str(value), extensions, safe_mode=safe_mode))) + else: + return mark_safe(markdown.markdown(force_unicode(value), extensions, safe_mode=safe_mode)) else: return mark_safe(force_unicode(markdown.markdown(smart_str(value)))) markdown.is_safe = True