def assert_rest2html(self, rest_string, html_string, strip_lines=False, debug=False, prepare_strings=True, **kwargs): # compare rest -> html if prepare_strings: rest_string = self._prepare_text(rest_string) html_string = self._prepare_text(html_string) html = rest2html(rest_string, **kwargs) if debug: print(rest_string) print(html_string) print(html) html = html.strip() # html = html.replace("<br />", "<br />\n") # html = tabs2spaces(html) if strip_lines: html = strip_html_lines(html, strip_lines) self.assertEqual(html, html_string, msg="rest2html")
def assert_rest2html(self, rest_string, html_string, \ strip_lines=False, debug=False, prepare_strings=True, **kwargs): # compare rest -> html if not REST_INSTALLED: warnings.warn("Skip ReSt test. Please install Docutils.") return if prepare_strings: rest_string = self._prepare_text(rest_string) html_string = self._prepare_text(html_string) html = rest2html(rest_string, **kwargs) if debug: print(rest_string) print(html_string) print(html) html = html.strip() # html = html.replace("<br />", "<br />\n") # html = tabs2spaces(html) if strip_lines: html = strip_html_lines(html, strip_lines) self.assertEqual(html, html_string, msg="rest2html")
def test_get_long_description_without_raise_errors(self): long_description = get_long_description(CREOLE_PACKAGE_ROOT, raise_errors=False) self.assertIn("=====\nabout\n=====\n\n", long_description) # Test created ReSt code from creole.rest_tools.clean_writer import rest2html html = rest2html(long_description) self.assertIn("<h1>about</h1>\n", html)
def apply_restructuretext(content, page_msg): from creole.exceptions import DocutilsImportError try: from creole.rest_tools.clean_writer import rest2html except DocutilsImportError: page_msg("Markup error: The Python docutils library isn't installed." " Download: http://docutils.sourceforge.net/") return fallback_markup(content) else: #docutils_settings = getattr(settings, "RESTRUCTUREDTEXT_FILTER_SETTINGS", {}) rest = rest2html(content) return rest