def creole2html(markup_string, debug=False, blog_line_breaks=True, **kwargs): """ convert creole markup into html code >>> creole2html(u'This is **creole //markup//**!') u'<p>This is <strong>creole <i>markup</i></strong>!</p>\\n' """ # Create document tree from creole markup document = Parser(markup_string, BlockRules(blog_line_breaks)).parse() if debug: document.debug() # Build html code from document tree return HtmlEmitter(document, **kwargs).emit()
def error(self, text, handle_traceback=False): """ Error Handling. """ if self.verbose > 1 and handle_traceback: self.stderr.write( "<pre>%s</pre>\n" % traceback.format_exc() ) if self.verbose > 0: return u"[Error: %s]\n" % text else: # No error output return u"" if __name__ == "__main__": txt = u"""this is **bold** ok? for example ** this sentence""" print "-" * 80 # from creole_alt.creole import Parser p = Parser(txt) document = p.parse() p.debug() html = HtmlEmitter(document).emit() print html print "-" * 79 print html.replace(" ", ".").replace("\n", "\\n\n")