def compile_html(self, source, dest, is_two_file=True): if creole is None: req_missing(['creole'], 'build this site (compile CreoleWiki)') makedirs(os.path.dirname(dest)) with codecs.open(dest, "w+", "utf8") as out_file: with codecs.open(source, "r", "utf8") as in_file: data = in_file.read() document = Parser(data).parse() output = HtmlEmitter(document).emit() out_file.write(output)
def compile(self, source, dest, is_two_file=True, post=None, lang=None): """Compile the source file into HTML and save as dest.""" if creole is None: req_missing(['creole'], 'build this site (compile CreoleWiki)') makedirs(os.path.dirname(dest)) with codecs.open(dest, "w+", "utf8") as out_file: with codecs.open(source, "r", "utf8") as in_file: data = in_file.read() document = Parser(data).parse() output = HtmlEmitter(document).emit() out_file.write(output)
def compile_html(self, source, dest): if creole is None: raise Exception('To build this site, you need to install the ' '"creole" package.') try: os.makedirs(os.path.dirname(dest)) except: pass with codecs.open(dest, "w+", "utf8") as out_file: with codecs.open(source, "r", "utf8") as in_file: data = in_file.read() document = Parser(data).parse() output = HtmlEmitter(document).emit() out_file.write(output)
#!/usr/bin/python # -*- coding: utf-8 -*- import sys from creole import Parser from creole.html_emitter import HtmlEmitter if __name__ == "__main__": document = Parser(str(sys.stdin.read(), 'utf-8', 'ignore')).parse() sys.stdout.write(HtmlEmitter(document).emit().encode('utf-8', 'ignore'))