@register.filter(is_safe=True)
def markdown(value, arg=''):
 import warnings
 warnings.warn('The markdown filter has been deprecated', category=DeprecationWarning)
 try:
  import markdown
 except ImportError:
  if settings.DEBUG:
   raise template.TemplateSyntaxError("Error in 'markdown' filter: The Python markdown library isn't installed.")
  return force_text(value)
 else:
  markdown_vers = getattr(markdown, 'version_info', 0)
  if (markdown_vers < (2, 1)):
   if settings.DEBUG:
    raise template.TemplateSyntaxError("Error in 'markdown' filter: Django does not support versions of the Python markdown library < 2.1.")
   return force_text(value)
  else:
   extensions = [e for e in arg.split(',') if e]
   if (extensions and (extensions[0] == 'safe')):
    extensions = extensions[1:]
    return mark_safe(markdown.markdown(force_text(value), extensions, safe_mode=True, enable_attributes=False))
   else:
    return mark_safe(markdown.markdown(force_text(value), extensions, safe_mode=False))

@ register . filter ( is_safe = True ) def markdown ( value , arg = '' ) : import warnings warnings . warn ( 'The markdown filter has been deprecated' , category = DeprecationWarning ) try : import markdown except ImportError : if settings . DEBUG : raise template . TemplateSyntaxError ( "Error in 'markdown' filter: The Python markdown library isn't installed." ) return force_text ( value ) else : markdown_vers = getattr ( markdown , 'version_info' , 0 ) if ( markdown_vers < ( 2 , 1 ) ) : if settings . DEBUG : raise template . TemplateSyntaxError ( "Error in 'markdown' filter: Django does not support versions of the Python markdown library < 2.1." ) return force_text ( value ) else : extensions = [ e for e in arg . split ( ',' ) if e ] if ( extensions and ( extensions [ 0 ] == 'safe' ) ) : extensions = extensions [ 1 : ] return mark_safe ( markdown . markdown ( force_text ( value ) , extensions , safe_mode = True , enable_attributes = False ) ) else : return mark_safe ( markdown . markdown ( force_text ( value ) , extensions , safe_mode = False ) )
runs markdown over a given value .