示例#1
0
 def test_stylesheets(self):
     """
     Test output for stylesheets
     """
     html_out = blogPreview(REST_ARTICLE, ["css/style1.css",
                                           "css/blogger1.css"])
     self.assertTrue('type="text/css"' in html_out)
     match = re.search(r'<link rel="stylesheet" '
                       'href=".*" type="text/css" />', html_out)
     self.assertTrue(match is not None)
     self.assertEqual(len(match.span()), 2)
示例#2
0
 def test_stylesheets(self):
     """
     Test output for stylesheets
     """
     html_out = blogPreview(REST_ARTICLE,
                            ["css/style1.css", "css/blogger1.css"])
     self.assertTrue('type="text/css"' in html_out)
     match = re.search(
         r'<link rel="stylesheet" '
         'href=".*" type="text/css" />', html_out)
     self.assertTrue(match is not None)
     self.assertEqual(len(match.span()), 2)
示例#3
0
 def test_content(self):
     """
     Simple case, check output
     """
     html_out = blogPreview(REST_ARTICLE)
     self.assertTrue(len(html_out) > 0)
     self.assertTrue("<html" in html_out)
     self.assertTrue("</html>" in html_out)
     self.assertTrue("<?xml version=\"1.0\" encoding=\"utf-8\"" in
                     html_out)
     self.assertTrue("\n\n<!-- more -->\n\n" in html_out)
     self.assertTrue("<title>Title — This is a test</title>" in html_out)
     self.assertTrue('type="text/css"' not in html_out)
     self.assertTrue(re.search(r"<h1.*><a href=\"#\">Title — This is a"
                               " test</a></h1>", html_out))
     self.assertTrue(re.search(r"<h2>Section 1</h2>", html_out))
     self.assertTrue(re.search(r"<h3>Subsection 1.1</h3>", html_out))
     self.assertTrue("description" not in html_out)
示例#4
0
 def test_content(self):
     """
     Simple case, check output
     """
     html_out = blogPreview(REST_ARTICLE)
     self.assertTrue(len(html_out) > 0)
     self.assertTrue("<html" in html_out)
     self.assertTrue("</html>" in html_out)
     self.assertTrue("<?xml version=\"1.0\" encoding=\"utf-8\"" in html_out)
     self.assertTrue("\n\n<!-- more -->\n\n" in html_out)
     self.assertTrue("<title>Title — This is a test</title>" in html_out)
     self.assertTrue('type="text/css"' not in html_out)
     self.assertTrue(
         re.search(
             r"<h1.*><a href=\"#\">Title — This is a"
             " test</a></h1>", html_out))
     self.assertTrue(re.search(r"<h2>Section 1</h2>", html_out))
     self.assertTrue(re.search(r"<h3>Subsection 1.1</h3>", html_out))
     self.assertTrue("description" not in html_out)
示例#5
0
    def preview(self):
        """
        Generate HTML Blogger article preview and (optionally) display it in
        systems' web browser
        """
        bufcontent = "\n".join(self.buff)
        name = self.buff.name

        name = name[:-4] + ".html"
        html = blogPreview(bufcontent, self.stylesheets)
        self._open_qf(self._check_html(html))

        output_file = open(name, "w")
        output_file.write(html)
        output_file.close()
        if vim.eval("g:blogger_browser"):
            webbrowser.open(name)
            return "Generated HTML has been opened in browser"
        else:
            return "Generated HTML has been written to %s" % name