def plain2rst(self): """Try to interpret the plain text as reStructuredText. """ charset = get_charset() rstText = self.plain ignored, warnings = rst.render( rstText, input_encoding=charset, output_encoding=charset) if len(warnings.messages) == 0: body = rst.HTML( rstText, input_encoding=charset, output_encoding=charset) else: # There are warnings, so we keep it simple. body = '<pre>%s</pre>' % rstText return body
def plain2rst(self): """Try to interpret the plain text as reStructuredText. """ charset = get_charset() rstText = self.plain ignored, warnings = rst.render(rstText, input_encoding=charset, output_encoding=charset) if len(warnings.messages) == 0: body = rst.HTML(rstText, input_encoding=charset, output_encoding=charset) else: # There are warnings, so we keep it simple. body = '<pre>%s</pre>' % rstText return body
def renderHTML(rstText, lang='en', charset='utf-8'): """Convert the given rST into a full XHTML transitional document. """ ignored, warnings = rst.render(rstText, input_encoding=charset, output_encoding=charset) if len(warnings.messages) == 0: body = rst.HTML(rstText, input_encoding=charset, output_encoding=charset) else: # There are warnings, so we keep it simple. body = '<pre>%s</pre>' % rstText kwargs = {'lang': lang, 'charset': charset, 'body': body} return htmlTemplate % kwargs
def renderHTML(rstText, lang='en', charset='utf-8'): """Convert the given rST into a full XHTML transitional document. """ ignored, warnings = rst.render( rstText, input_encoding=charset, output_encoding=charset) if len(warnings.messages) == 0: body = rst.HTML( rstText, input_encoding=charset, output_encoding=charset) else: # There are warnings, so we keep it simple. body = '<pre>%s</pre>' % rstText kwargs = {'lang': lang, 'charset': charset, 'body': body} return htmlTemplate % kwargs