<s> from . base_renderer import * <EOL> import re <EOL> import markdown <EOL> @ renderer <EOL> class MarkdownRenderer ( MarkupRenderer ) : <EOL> FILENAME_PATTERN_RE = re . compile ( r'<STR_LIT>' ) <EOL> YAML_FRONTMATTER_RE = re . compile ( r'<STR_LIT>' , re . DOTALL | re . MULTILINE ) <EOL> MARKDOWN_SYNTAX_RE = re . compile ( r'<STR_LIT>' ) <EOL> def load_settings ( self , renderer_options , global_setting ) : <EOL> super ( MarkdownRenderer , self ) . load_settings ( renderer_options , global_setting ) <EOL> if '<STR_LIT>' in renderer_options : <EOL> extensions = renderer_options [ '<STR_LIT>' ] <EOL> else : <EOL> extensions = [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] <EOL> extensions = set ( extensions ) <EOL> if global_setting . mathjax_enabled : <EOL> if '<STR_LIT>' not in extensions : <EOL> extensions . add ( '<STR_LIT>' ) <EOL> if '<STR_LIT>' in extensions : <EOL> extensions . remove ( '<STR_LIT>' ) <EOL> extensions . add ( '<STR_LIT>' ) <EOL> if '<STR_LIT>' in extensions : <EOL> extensions . remove ( '<STR_LIT>' ) <EOL> extensions . add ( '<STR_LIT>' ) <EOL> self . extensions = list ( extensions ) <EOL> @ classmethod <EOL> def is_enabled ( cls , filename , syntax ) : <EOL> """<STR_LIT>""" <EOL> if cls . MARKDOWN_SYNTAX_RE . match ( syntax ) : <EOL> return True <EOL> return cls . FILENAME_PATTERN_RE . search ( filename ) is not None <EOL> def render ( self , text , ** kwargs ) : <EOL> text = self . YAML_FRONTMATTER_RE . sub ( '<STR_LIT>' , text ) <EOL> return markdown . markdown ( text , output_format = '<STR_LIT>' , <EOL> extensions = self . extensions ) </s>
