예제 #1
0
 @Test
 public void testHtmlContainsOuter() {
   Document doc = Jsoup.parse("<title>Check</title> <div>Hello there</div>");
   doc.outputSettings().indentAmount(0);
   assertTrue(doc.html().contains(doc.select("title").outerHtml()));
   assertTrue(doc.html().contains(doc.select("div").outerHtml()));
 }
예제 #2
0
 @Test
 public void testSetIndent() {
   Document doc = Jsoup.parse("<div><p>Hello\nthere</p></div>");
   doc.outputSettings().indentAmount(0);
   assertEquals(
       "<html>\n<head></head>\n<body>\n<div>\n<p>Hello there</p>\n</div>\n</body>\n</html>",
       doc.html());
 }
예제 #3
0
 @Test
 public void testFormatOutline() {
   Document doc =
       Jsoup.parse(
           "<title>Format test</title><div><p>Hello <span>jsoup <span>users</span></span></p><p>Good.</p></div>");
   doc.outputSettings().outline(true);
   assertEquals(
       "<html>\n <head>\n  <title>Format test</title>\n </head>\n <body>\n  <div>\n   <p>\n    Hello \n    <span>\n     jsoup \n     <span>users</span>\n    </span>\n   </p>\n   <p>Good.</p>\n  </div>\n </body>\n</html>",
       doc.html());
 }
예제 #4
0
  @Test
  public void testNotPretty() {
    Document doc = Jsoup.parse("<div>   \n<p>Hello\n there\n</p></div>");
    doc.outputSettings().prettyPrint(false);
    assertEquals(
        "<html><head></head><body><div>   \n<p>Hello\n there\n</p></div></body></html>",
        doc.html());

    Element div = doc.select("div").first();
    assertEquals("   \n<p>Hello\n there\n</p>", div.html());
  }