Esempio n. 1
0
def main(text):
    g = MarkdownGrammar()
    resultSoFar = []
    result, rest = g.parse(text, resultSoFar=resultSoFar, skipWS=False)
#    print rest.encode('gbk'), result[0].render()
#    print '--------------------------'
#    print SimpleVisitor().visit(result).encode('gbk')
#    print '--------------------------'
    v = MarkdownHtmlVisitor(template, tag_class, g)
    print v.template(result).encode('utf8')
Esempio n. 2
0
File: md2html.py Progetto: lowks/par
    def parseHtml(text, template=None, tag_class=None, block_callback=None, init_callback=None):
        template = template or ''
        tag_class = tag_class or {}
        g = MarkdownGrammar()
        resultSoFar = []
        result, rest = g.parse(text, resultSoFar=resultSoFar, skipWS=False
#            ,root=g['dl_dd_2']
            )
        v = MarkdownHtmlVisitor(template, tag_class, g, block_callback=block_callback, init_callback=init_callback)
        print(result[0].render())
        return v.template(result)