import markdown import bs4 import textwrap template = __SIBYL_COMPONENT_TAG__ template_str = "".join(str(content) for content in template.contents) # Using the textwrap.dedent function to remove common leading whitespace template_str = textwrap.dedent(template_str) text = markdown.markdown(template_str, extensions=['markdown.extensions.extra', 'markdown.extensions.codehilite']) soup = bs4.BeautifulSoup(text, "html.parser") template.contents = soup.contents __SIBYL_HALT_COMPONENTS__ = True __SIBYL_HALT_COMPONENTS__ = None