Commits

Vladimir Ermakov committed 1b0c10c

Fix markdown template filter

  • Participants
  • Parent commits 90857d5

Comments (0)

Files changed (1)

apps/lib/templatetags/bfmarkup.py

 def markdown(value, arg=''):
     """
     Runs Markdown over a given value, optionally using various
-    extensions python-markdown supports.
+    extensions python-markdown2 supports.
 
     Syntax::
 
 
     """
     try:
-        import markdown
+        import markdown2
     except ImportError:
         if settings.DEBUG:
-            raise template.TemplateSyntaxError, "Error in {% markdown %} filter: The Python markdown library isn't installed."
+            raise template.TemplateSyntaxError, "Error in {% markdown %} filter: The Python markdown2 library isn't installed."
         return force_unicode(value)
     else:
-        # markdown.version was first added in 1.6b. The only version of markdown
-        # to fully support extensions before 1.6b was the shortlived 1.6a.
-        if hasattr(markdown, 'version'):
-            extensions = [e for e in arg.split(",") if e]
-            if len(extensions) > 0 and extensions[0] == "safe":
-                extensions = extensions[1:]
-                safe_mode = True
-            else:
-                safe_mode = False
-            # markdown 1.6 was the first to add proper unicode support
-            if markdown.version_info < (1,6):
-                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))
+       	extensions = [e for e in arg.split(",") if e]
+        if len(extensions) > 0 and extensions[0] == "safe":
+            extensions = extensions[1:]
+            safe_mode = True
         else:
-            return mark_safe(force_unicode(markdown.markdown(smart_str(value))))
+            safe_mode = False
+        return mark_safe(markdown2.markdown(force_unicode(value), extras=extensions, safe_mode=safe_mode))
 markdown.is_safe = True