<s> from django import template <EOL> from django . conf import settings <EOL> register = template . Library ( ) <EOL> @ register . filter <EOL> def safe_markdown ( value , arg = '<STR_LIT>' ) : <EOL> """<STR_LIT>""" <EOL> try : <EOL> import markdown <EOL> except ImportError : <EOL> if settings . DEBUG : <EOL> raise template . TemplateSyntaxError ( <EOL> '<STR_LIT>' ) <EOL> else : <EOL> from django . utils . html import escape , linebreaks <EOL> return linebreaks ( escape ( value ) ) <EOL> else : <EOL> extensions = arg . split ( "<STR_LIT:U+002C>" ) <EOL> if len ( extensions ) > <NUM_LIT:0> and extensions [ <NUM_LIT:0> ] == "<STR_LIT>" : <EOL> extensions = extensions [ <NUM_LIT:1> : ] <EOL> safe_mode = True <EOL> else : <EOL> safe_mode = False <EOL> return markdown . markdown ( value , extensions , safe_mode = safe_mode ) </s>
