A mirror of my website's source code.

By using this site, you agree to have cookies stored on your device, strictly for functional purposes, such as storing your session and preferences.

Dismiss

 Renderers.py

View raw Download
text/x-script.python • 728 B
Python script, ASCII text executable
        
            
1
from jinja2 import Environment as JinjaEnv, FileSystemLoader as JinjaFS
2
from markdown2 import Markdown as MDEnv
3
4
__TemplateRenderer__ = JinjaEnv(loader=JinjaFS(searchpath="./views"))
5
6
def RenderTemplate(TemplateFileName: str, *args, **kwargs):
7
"""Renders a Jinja2 template from a file."""
8
return __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
12
def RenderMarkdown(MDSource: str):
13
"""Renders Markdown, but pre-configured."""
14
return __MDRenderer__.convert(MDSource)