Package org.asciidoctor.ast

Examples of org.asciidoctor.ast.StructuredDocument


  public void empty_parent_title_makes_subsection_be_null_when_is_parsed() {

    String s = "= My page\n" + "\n" + "== Totally ignored header\n" + "\n"
        + "What does it mean?\n";

    StructuredDocument structuredDocument = asciidoctor
        .readDocumentStructure(s, new java.util.HashMap());
   
    List<ContentPart> parts = structuredDocument.getParts();

  }
View Full Code Here


  @Test
  public void structural_content_should_be_retrieved_from_file() {

    Map<String, Object> parameters = new HashMap<String, Object>();
    parameters.put(Asciidoctor.STRUCTURE_MAX_LEVEL, 2);
    StructuredDocument document = asciidoctor.readDocumentStructure(
        new File("target/test-classes/documentblocks.asciidoc"),
        parameters);

    DocumentHeader header = document.getHeader();

    assertThat(header.getDocumentTitle().getMain(), is("Sample Document"));
    assertThat(header.getPageTitle(), is("Sample Document"));

    Map<String, Object> attributes = header.getAttributes();
    assertThat((String) attributes.get("revdate"), is("2013-05-20"));
    assertThat((String) attributes.get("revnumber"), is("1.0"));
    assertThat((String) attributes.get("revremark"), is("First draft"));
    // attributes should be incasesensitive
    assertThat((String) attributes.get("tags"), is("[document, example]"));
    assertThat((String) attributes.get("Tags"), is("[document, example]"));
    assertThat((String) attributes.get("author"), is("Doc Writer"));
    assertThat((String) attributes.get("email"),
        is("doc.writer@asciidoc.org"));

    List<ContentPart> parts = document.getParts();

    assertThat(parts, notNullValue());
    assertThat(parts, hasSize(3));

    assertThat(parts.get(0).getContext(), is("section"));
View Full Code Here

    assertThat(parts.get(2).getParts().get(1).getContext(), is("image"));
  }

  @Test
  public void some_real_content() {
    StructuredDocument document = asciidoctor.readDocumentStructure(
        new File("target/test-classes/contentstructure.asciidoc"),
        new HashMap<String, Object>());

    DocumentHeader header = document.getHeader();

    assertThat(header.getDocumentTitle().getMain(), is("TODO"));
    assertThat(header.getDocumentTitle().getSubtitle(), is("Document Title"));
   
    Map<String, Object> attributes = header.getAttributes();
    assertThat((String) attributes.get("type"), is("object.type"));

    List<ContentPart> parts = document.getParts();

    assertThat(parts, notNullValue());
    assertThat(parts, hasSize(4));

    assertThat(document.getPartByStyle("literal").getContent(),
        is("TODO: This is description"));

    List<ContentPart> images = document.getPartsByContext("image");
    assertThat(images, hasSize(2));
    for (int i = 0; i < 2; i++) {
      assertThat((String) images.get(i).getAttributes().get("target"),
          is("src/some image " + (i + 1) + ".JPG"));
      assertThat((String) images.get(i).getAttributes().get("alt"),
          is("TODO title" + (i + 1)));
      assertThat((String) images.get(i).getAttributes().get("link"),
          is("link" + (i + 1) + ".html"));
    }
    assertThat(document.getPartByStyle("Open").getContent(),
        startsWith("<div class=\"paragraph text-center\">"));
  }
View Full Code Here

  }

  @Test
  public void title_should_be_retrieved_from_simple_string() {

    StructuredDocument document = asciidoctor.readDocumentStructure(
        "= Sample Document", new HashMap<String, Object>());

    DocumentHeader header = document.getHeader();

    assertThat(header.getDocumentTitle().getMain(), is("Sample Document"));

    List<ContentPart> parts = document.getParts();

    assertThat(parts, notNullValue());
    assertThat(parts, hasSize(0));

  }
View Full Code Here

  }

  @Test
  public void one_part_should_be_retrieved_from_simple_string() {

    StructuredDocument document = asciidoctor.readDocumentStructure(
        "Simple single paragraph", new HashMap<String, Object>());

    DocumentHeader header = document.getHeader();

    assertThat(header, notNullValue());

    List<ContentPart> parts = document.getParts();

    assertThat(parts, notNullValue());
    assertThat(parts, hasSize(1));
    assertThat(parts.get(0).getContent(), is("Simple single paragraph"));
View Full Code Here

  }

  @Test
  public void no_parts_should_be_retrieved_from_empty_string() {

    StructuredDocument document = asciidoctor.readDocumentStructure("",
        new HashMap<String, Object>());

    DocumentHeader header = document.getHeader();

    assertThat(header, notNullValue());

    List<ContentPart> parts = document.getParts();

    assertThat(parts, notNullValue());
    assertThat(parts, hasSize(0));
  }
View Full Code Here

                  .attribute("allow-uri-read")
                  .attribute("copycss!", "").asMap())
          .asMap();
     
      if (part != null && !"all".equals(part)){
        StructuredDocument document = asciidoctor.readDocumentStructure(
            source, parameters);
        if (backend.equals("dzslides") && document != null  && document.getPartById(part) != null) {
          parameters.put(Asciidoctor.STRUCTURE_MAX_LEVEL, 2);
          ContentPart p = document.getPartById(part);
          output = getHeaderForSlides() + "<body><"+ p.getContext() +" class=\""+ p.getRole() + "\">"+ "<h2>" + p.getTitle() + "</h2>" + p.getContent() + "</"+ p.getContext() +">" + getBodyFooterForSlides() +"</body>";
        }
      }
     
      if (output == null)
View Full Code Here

TOP

Related Classes of org.asciidoctor.ast.StructuredDocument

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.