def get_markdown(text, safe_mode=False): md = markdown.Markdown(source=text, safe_mode=safe_mode) _register_mdx_extensions(md) md.postprocessors += wiki_processors return md
def makeExtension(configs={}): return MacroExtension(configs=configs) #-- sample macros @macro def HelloWorld(): """Hello world macro.""" return "<b>Hello, world</b>." @macro def ListOfMacros(): """Lists all available macros.""" out = "" out += "<ul>" for name, macro in macrostore.items(): out += ' <li><b>%s</b>: %s</li>\n' % (name, macro.__doc__ or "") out += "</ul>" return out if __name__ == "__main__": text = "{{HelloWorld()}}" md = markdown.Markdown(source=text, safe_mode=False) MacroExtension().extendMarkdown(md, {}) html = md.convert() print(replace_macros(html, md.macros))