def from_string(s): f = StringIO(s) return Document.from_parseTree(regl.parseString( ''.join(ReglLexer(f)))[0])
"text": c_text} class NBNode(SectionNode): def pre_to_html(self, ctx): pass def to_html(self, children, ctx): c_text = '' if children is None else ''.join(children) return """ <div class="NBTitle">%s</div> <div class='NB'>%s</div> """ % ( self.title, c_text) def to_LaTeX(self, children, ctx): c_text = '' if children is None else ''.join(children) title = self.title return r""" \theoremstyle{comment} \newtheorem*{%(title)s}{%(title)s} \begin{%(title)s} %(text)s \end{%(title)s} """ % {"title": title, "text": c_text} if __name__ == '__main__': import codecs with codecs.open('test.regl', 'r', 'utf-8') as f: doc = Document.from_parseTree(regl.parseString( ''.join(ReglLexer(f)))[0]) with codecs.open('test.tex', 'w', 'utf-8') as f2: f2.write(doc.to_LaTeX())