Beispiel #1
0
 def test_markup(self):
     c = markup.render_as_rich_text(RST, "text/x-rst",)
     self.assertIn("<", c)
     c = markup.render_as_rich_text(MD, "text/markdown")
     self.assertTrue(c.startswith("<"))
     c = markup.render_as_rich_text(HTML, "text/html")
     self.assertTrue(c.startswith("<"))
     c = markup.render_as_rich_text(RST, "text/plain")
     self.assertIn("<", c)
Beispiel #2
0
def description_rich_text(item):  # type: (Item) -> str
    description = ""     # type: str
    content_type = None  # type: Optional[str]

    if isinstance(item, Installed):
        remote, dist = item.installable, item.local
        if remote is None:
            meta = get_dist_meta(dist)
            description = meta.get("Description", "") or \
                          meta.get('Summary', "")
            content_type = meta.get("Description-Content-Type")
        else:
            description = remote.description
            content_type = remote.description_content_type
    else:
        description = item.installable.description
        content_type = item.installable.description_content_type

    try:
        html = markup.render_as_rich_text(description, content_type)
    except Exception:
        html = markup.render_as_rich_text(description, "text/plain")
    return html
Beispiel #3
0
 def __updateRenderedContent(self):
     # type: () -> None
     self.__textItem.setHtml(
         markup.render_as_rich_text(self.__content, self.__contentType))