Exemplo n.º 1
0
 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
Exemplo n.º 2
0
 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
Exemplo n.º 3
0
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
Exemplo n.º 4
0
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