Renderers.py
Python script, ASCII text executable
1from jinja2 import Environment as JinjaEnv, FileSystemLoader as JinjaFS 2from markdown2 import Markdown as MDEnv 3 4__TemplateRenderer__ = JinjaEnv(loader=JinjaFS(searchpath="./views")) 5 6def RenderTemplate(TemplateFileName: str, *args, **kwargs): 7"""Renders a Jinja2 template from a file.""" 8return __TemplateRenderer__.get_template(TemplateFileName).render(*args, **kwargs) 9 10__MDRenderer__ = MDEnv(extras=["header-ids", "metadata", "markdown-in-html", "code-friendly", "footnotes", "fenced-code-blocks"], footnote_title="Jump back to footnote %d in the text.", footnote_return_symbol="↩") 11 12def RenderMarkdown(MDSource: str): 13"""Renders Markdown, but pre-configured.""" 14return __MDRenderer__.convert(MDSource)