예제 #1
0
class markdown2html(object):
    def __init__(self):
        self._md_latex = MdLatexSupport()

    def parse(self, md_text, reduce_to_tree=False, reduce_tag='div'):
        secured_markdown = self._md_latex.prepare(md_text)
        html_secured = markdown.markdown(secured_markdown, extensions=[
            'markdown.extensions.sane_lists',
            'markdown.extensions.nl2br'])
        html = self._md_latex.finish(html_secured)

        if not reduce_to_tree:
            return html
        try:
            return ET.fromstring(html)
        except Exception as e:
            return ET.fromstring('<' + reduce_tag + '>' + html + '</' + reduce_tag + '>')
class markdown2html(object):
    def __init__(self):
        self._md_latex = MdLatexSupport()

    def parse(self, md_text, reduce_to_tree=False, reduce_tag='div'):
        secured_markdown = self._md_latex.prepare(md_text)
        html_secured = markdown.markdown(secured_markdown, extensions=[
            'markdown.extensions.sane_lists',
            'markdown.extensions.nl2br',
            'ist.formatters.extensions.md_links'])
        html = self._md_latex.finish(html_secured)

        if not reduce_to_tree:
            return html
        try:
            return ET.fromstring(html)
        except Exception as e:
            return ET.fromstring('<' + reduce_tag + '>' + html + '</' + reduce_tag + '>')
예제 #3
0
 def __init__(self):
     self._md_latex = MdLatexSupport()
 def __init__(self):
     self._md_latex = MdLatexSupport()