Package org.asciidoctor.ast

Examples of org.asciidoctor.ast.DocumentHeader


  private Asciidoctor asciidoctor = JRubyAsciidoctor.create();
 
  @Test
  public void doctitle_blocks_and_attributes_should_be_returned() {
   
    DocumentHeader header = asciidoctor.readDocumentHeader(new File("target/test-classes/documentheaders.asciidoc"));
   
   
    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]"));
View Full Code Here


  }
 
  @Test
  public void author_info_should_be_bound_into_author_class() {
   
    DocumentHeader header = asciidoctor.readDocumentHeader(new File("target/test-classes/documentheaders.asciidoc"));
   
    Author author = header.getAuthor();
    assertThat(author.getEmail(), is("doc.writer@asciidoc.org"));
    assertThat(author.getFullName(), is("Doc Writer"));
    assertThat(author.getFirstName(), is("Doc"));
    assertThat(author.getLastName(), is("Writer"));
    assertThat(author.getInitials(), is("DW"));
View Full Code Here

  }
 
  @Test
  public void revision_info_should_be_bound_into_revision_info_class() {
   
    DocumentHeader header = asciidoctor.readDocumentHeader(new File("target/test-classes/documentheaders.asciidoc"));
   
    RevisionInfo revisionInfo = header.getRevisionInfo();
   
    assertThat(revisionInfo.getDate(), is("2013-05-20"));
    assertThat(revisionInfo.getNumber(), is("1.0"));
    assertThat(revisionInfo.getRemark(), is("First draft"));
   
View Full Code Here

 
 
  @Test
  public void multiple_authors_should_be_bound_into_list_of_authors() {
   
    DocumentHeader header = asciidoctor.readDocumentHeader(new File("target/test-classes/documentheaders.asciidoc"));
   
    List<Author> authors = header.getAuthors();
    assertThat(authors, hasSize(2));
   
    Author author1 = authors.get(0);
   
    assertThat(author1.getEmail(), is("doc.writer@asciidoc.org"));
View Full Code Here

    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]"));
View Full Code Here

  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());
View Full Code Here

  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

  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();
View Full Code Here

  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();
View Full Code Here

   * @param source the AsciiDoc source sent by the client
   * @return the DocumentHeader
   */
  private DocumentHeader checkHeader (String source){
    //Check if document header is present
    DocumentHeader docHeader = null;
    try {
      logger.info("[RENDER] processing DocumentHeader");

      docHeader = processor.renderDocumentHeader(source);
      for (Map.Entry<String, Object> h : docHeader.getAttributes().entrySet()){
        logger.log(Level.FINER, h.getKey() + " : " + h.getValue());
      }
      //FIXME : check which headers are mandatory
      Map<String, Object> headers = docHeader.getAttributes();
      if (docHeader.getAuthors().size() == 0) {
        logger.info("DocHeader add author");
        headers.put("author", "the Author");
        headers.put("email", "test@test.fr");
      }
      docHeader = DocumentHeader.createDocumentHeader("Doc title", "page title", headers);
View Full Code Here

TOP

Related Classes of org.asciidoctor.ast.DocumentHeader

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.