class

Asciidoctor::Document

Inherits Asciidoctor::AbstractBlock < Asciidoctor::Substitutors < Asciidoctor::AbstractNode < Asciidoctor::Logging < Reference < Object

The Document class represents a parsed AsciiDoc document.

Document is the root node of a parsed AsciiDoc document. It provides an abstract syntax tree (AST) that represents the structure of the AsciiDoc document from which the Document object was parsed.

Constructors

new(safe : Int32 = SafeMode::SECURE, backend : String = DEFAULT_BACKEND, doctype : String = DEFAULT_DOCTYPE, base_dir : String = ".", sourcemap : Bool = false, parent_document : Document | Nil = nil, options : Hash(String, String | Bool | Int32) = {} of String => String | Bool | Int32)
Source

Instance methods

<<(block : AbstractBlock) : self

Append a content block to this block's list of blocks. If the child block is a Section, assign an index to it.

Source
apply_attribute_value_subs(value : String) : String

Internal: Apply substitutions to the attribute value.

If the value is an inline passthrough macro (e.g., pass:<subs>[value]), apply the substitutions defined in <subs> to the value, or leave the value unmodified if no substitutions are specified. If the value is not an inline passthrough macro, apply header substitutions to the value.

Source
attribute_locked?(name : String) : Bool

Check if the specified attribute is locked (set via overrides).

Source
attribute_overrides

The attribute overrides (locked attributes).

Source
author

Get the author.

Source
authors

Get the Array of authors.

Source
backend

The cached value of the backend attribute.

Source
base_dir

The String base directory for converting this document.

Source
basebackend?(base : String) : Bool

Check whether the current backend matches the base backend.

Source
callouts

Get the callouts.

Source
catalog

The document catalog Hash.

Source
clear_playback_attributes(attrs : Hash(String, String)) : Nil

Internal: Delete any attributes stored for playback.

Source
compat_mode?

The Boolean AsciiDoc compatibility mode.

Source
content

Get the converted result of the child blocks.

Source
convert(opts : Hash(String, String) = {} of String => String) : String | Nil

Convert the AsciiDoc document using the converter.

Source
converter

The Converter associated with this document.

Source
converter=(converter : Converter::Base | Nil)

The Converter associated with this document.

Source
counter(name : String, seed : String | Int32 | Nil = nil) : String | Int32

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

Source
counters

The Hash of document counters.

Source
create_converter(backend_name : String) : Converter::Base

Internal: Create and initialize an instance of the converter for this document.

Source
create_converter

Create or retrieve the converter for this document. Uses the DefaultRegistry to find a converter matching the backend.

Source
delete_attribute(name : String) : Bool

Delete the specified attribute from the document if the name is not locked.

Source
docinfo(location : Symbol = :head, suffix : String | Nil = nil) : String

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

Source
doctitle(opts : Hash(Symbol, Bool) = {} of Symbol => Bool) : String | Nil

Get the doctitle as a String.

Source
doctitle_as_title(separator : String = ":") : Title | Nil

Get the document title as a Title object.

Source
doctype

The cached value of the doctype attribute.

Source
document
Source
embedded?

Check if the document is embedded.

Source
extensions

The activated Extensions::Registry associated with this document.

Source
extensions!

Get the extensions registry, raising if nil.

Source
extensions=(extensions : Extensions::Registry | Nil)

The activated Extensions::Registry associated with this document.

Source
extensions?

Check if the document has extensions.

Source
fill_datetime_attributes(attrs : Hash(String, String), input_mtime : Time | Nil = nil) : Nil

Internal: Assign the local and document datetime attributes.

Source
finalize_header(block_attrs : Hash(String, String), apply_header : Bool = true) : Hash(String, String)

Finalize the document header after parsing.

Source
first_section

Get the first section of the document.

Source
footnotes

Get the footnotes.

Source
footnotes?

Check whether this document has footnotes.

Source
header

The level-0 Section (i.e., doctitle).

Source
header=(header : Section | Nil)

The level-0 Section (i.e., doctitle).

Source
header?

Check whether this document has a header.

Source
increment_and_store_counter(counter_name : String, block : AbstractBlock | Nil = nil) : String

Increment and store a counter.

Source
init_syntax_highlighter

Initialize the syntax highlighter based on the source-highlighter attribute.

Source
max_attribute_value_size

The maximum attribute value size.

Source
max_attribute_value_size=(max_attribute_value_size : Int32 | Nil)

The maximum attribute value size.

Source
multipart?

Check if this is a multipart (book) document.

Source
nested?

Check if the document is nested (i.e., has a parent document).

Source
nofooter

Check if the document should not render a footer.

Source
noheader

Check if the document should not render a header.

Source
notitle

Check if the document should not render a title.

Source
options

The Hash of resolved options.

Source
outfilesuffix

The outfilesuffix defined at the end of the header.

Source
parent_document

A reference to the parent Document of this nested document.

Source
parse(data : Array(String) | String | Nil = nil) : self

Parse the AsciiDoc source stored in the Reader into an abstract syntax tree.

Source
parsed

Whether the document has been parsed.

Source
parsed=(parsed : Bool)

Whether the document has been parsed.

Source
parsed?

Check whether the source has been parsed.

Source
playback_attributes(attrs : Hash(String, String)) : Nil

Replay attribute assignments at the block level. Processes attr_entries stored in block attributes during parsing.

Source
reader

The Reader associated with this document.

Source
reader=(reader : Reader | Nil)

The Reader associated with this document.

Source
register(type : Symbol, value : String | Array(String) | Tuple(String, AbstractNode)) : AbstractNode | Nil

Register a reference in the document catalog.

Source
resolve_id(text : String) : String | Nil

Resolve a string to an id.

Source
restore_attributes

Restore the attributes to the previously saved state (attributes in header).

Source
revdate

Get the revision date.

Source
safe

A read-only integer value indicating the level of security.

Source
save_attributes

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

Source
save_to(output : String, target : String) : Nil

Write the output to the specified file.

Source
sections?

Check whether this Document has any child Section objects.

Source
set_attribute(name : String, value : String = "") : String | Nil

Set the specified attribute on the document if the name is not locked.

Source
set_header_attribute(name : String, value : String = "", overwrite : Bool = true) : Bool

Assign a value to the specified attribute in the document header.

Source
source

Make the raw source for the Document available.

Source
source_lines

Get the source lines of the document.

Source
sourcemap=(sourcemap : Bool)

Whether source map information should be tracked by the parser.

Source
sourcemap?

Whether source map information should be tracked by the parser.

Source
syntax_highlighter

The SyntaxHighlighter associated with this document.

Source
syntax_highlighter=(syntax_highlighter : SyntaxHighlighterBase | Nil)

The SyntaxHighlighter associated with this document.

Source
update_backend_attributes(new_backend : String, init : Bool = false) : String | Nil

Internal: Update the backend attributes to reflect a change in the active backend.

Source
update_doctype_attributes(new_doctype : String) : String | Nil

Internal: Update the doctype attributes to reflect a change in the active doctype.

Source
write(output : String | Nil, target : String) : Nil

Write the output to the specified file.

Source
xreftext(xrefstyle : String | Nil = nil) : String | Nil

Generate cross reference text for this document.

Source

Nested types