document.rb

Path: lib/asciidoctor/document.rb
Last Update: Fri Jun 28 20:33:28 +0000 2013

Methods

Public Class methods

Public: Initialize an Asciidoc object.

data - The Array of Strings holding the Asciidoc source document. (default: []) options - A Hash of options to control processing, such as setting the safe mode (:safe),

          suppressing the header/footer (:header_footer) and attribute overrides (:attributes)
          (default: {})

block - A block that can be used to retrieve external Asciidoc

          data to include in this document.

Examples

  data = File.readlines(filename)
  doc  = Asciidoctor::Document.new(data)
  puts doc.render

Public Instance methods

Internal: Apply substitutions to the attribute value

If the value is an inline passthrough macro (e.g., pass:[text]), then apply the substitutions defined on the macro to the text. Otherwise, apply the verbatim substitutions to the value.

value - The String attribute value on which to perform substitutions

Returns The String value with substitutions performed.

Public: Determine if the attribute has been locked by being assigned in document options

key - The attribute key to check

Returns true if the attribute is locked, false otherwise

Public: Convenience method to retrieve the document attribute ‘author

returns the full name of the author as a String

Internal: Delete any attributes stored for playback

Public: Get the named counter and take the next number in the sequence.

name - the String name of the counter seed - the initial value as a String or Integer

returns the next number in the sequence for the specified counter

Public: Increment the specified counter and store it in the block‘s attributes

counter_name - the String name of the counter attribute block - the Block on which to save the counter

returns the next number in the sequence for the specified counter

Public: Delete the specified attribute from the document if the name is not locked

If the attribute is locked, false is returned. Otherwise, the attribute is deleted.

name - the String attribute name

returns true if the attribute was deleted, false if it was not because it‘s locked

Public: Read the docinfo file(s) for inclusion in the document template

If the docinfo1 attribute is set, read the docinfo.ext file. If the docinfo attribute is set, read the doc-name.docinfo.ext file. If the docinfo2 attribute is set, read both files in that order.

ext - The extension of the docinfo file(s). If not set, the extension

      will be determined based on the basebackend. (default: nil)

returns The contents of the docinfo file(s)

We need to be able to return some semblance of a title

QUESTION move to AbstractBlock?

name()

Alias for doctitle

Internal: Get the next value in the sequence.

Handles both integer and character sequences.

current - the value to increment as a String or Integer

returns the next value in the sequence according to the current value‘s type

Internal: Replay attribute assignments at the block level

Public: Render the Asciidoc document using the templates loaded by Renderer. If a :template_dir is not specified, or a template is missing, the renderer will fall back to using the appropriate built-in template.

Internal: Restore the attributes to the previously saved state

Public: Convenience method to retrieve the document attribute ‘revdate

returns the date of last revision for the document as a String

Internal: Branch the attributes so that the original state can be restored at a future time.

Public: Set the specified attribute on the document if the name is not locked

If the attribute is locked, false is returned. Otherwise, the value is assigned to the attribute name after first performing attribute substitutions on the value. If the attribute name is ‘backend’, then the value of backend-related attributes are updated.

name - the String attribute name value - the String attribute value

returns true if the attribute was set, false if it was not set because it‘s locked

Make the raw source for the Document available.

Make the raw source lines for the Document available.

The title explicitly defined in the document attributes

Public: Update the backend attributes to reflect a change in the selected backend

[Validate]