class

Asciidoctor::PreprocessorReader

Inherits Asciidoctor::Reader < Asciidoctor::Logging < Reference < Object

Public: Methods for retrieving lines from AsciiDoc source files, evaluating preprocessor directives as each line is read off the Array of lines.

Constructors

new(document : Document, data : Array(String) | String | Nil = nil, cursor : Cursor | String | Nil = nil, opts = {} of Symbol => String | Bool)
Source

Instance methods

conditional_stack

The stack of conditional directives being tracked.

Source
create_include_cursor(file : String, path : String, lineno : Int32) : Cursor

Create a Cursor for an include file.

Source
document

The document this reader is associated with.

Source
empty?

Check whether this reader is empty (contains no lines). Overrides Reader#empty? to pop the include stack if needed.

Source
eof?

Alias for empty?

Source
exceeds_max_depth?

Reports whether pushing an include on the include stack exceeds the max include depth.

Returns nil if no max depth is set and includes are disabled (max-include-depth=0), false if the current max depth will not be exceeded, and the relative max include depth if the current max depth will be exceeded.

Source
has_more_lines?

Check whether there are any lines left to read. Overrides Reader#has_more_lines? to use peek_line (which pops include stack).

Source
include_depth

Get the current include depth (number of includes on the stack).

Source
include_processors?

Check whether there are include processor extensions registered.

Source
include_stack

The include stack tracks nested includes.

Source
peek_line(direct : Bool = false) : String | Nil

Override the Reader#peek_line method to pop the include stack if the last line has been reached and there's at least one include on the stack.

Source
pop_include

Pop the current include context off the stack and restore the previous context.

Source
preprocess_conditional_directive(name : String, target : String, delimiter : String | Nil, text : String | Nil) : Bool

Internal: Preprocess the directive to conditionally include or exclude content.

name - The name of the conditional inclusion directive (ifdef, ifndef, ifeval, endif) target - The target, which is the name of one or more attributes delimiter - The conditional delimiter for multiple attributes ('+' or ',') text - The text associated with this directive (between square brackets)

Returns a Boolean indicating whether the cursor should be advanced.

Source
preprocess_include_directive(target : String, attrlist : String | Nil) : Bool

Internal: Preprocess the directive to include lines from another document.

target - The unsubstituted String name of the target document attrlist - An attribute list String (text between square brackets)

Returns a Boolean indicating whether the line under the cursor was changed.

Source
push_include(data : Array(String) | String, file : String | Nil = nil, path : String | Nil = nil, lineno : Int32 = 1, attributes : Hash(String, String) = {} of String => String) : self

Push source onto the front of the reader and switch the context based on the file, document-relative path and line information given.

Source
resolve_expr_val(val : String) : String | Int32 | Float64 | Bool | Nil

Internal: Resolve the value of one side of an ifeval expression.

Returns the resolved value (String, Int32, Float64, Bool, or Nil).

Source
skip_front_matter!(data : Array(String), increment_linenos : Bool = true) : Array(String) | Nil

Private: Ignore front-matter, commonly used in static site generators.

data - The Array of String source lines increment_linenos - Whether to increment line numbers (default: true)

Returns the Array of front-matter lines, or nil if not detected.

Source
skipping=(skipping : Bool)

Whether the reader is currently skipping lines (inside a false conditional).

Source
skipping?

Whether the reader is currently skipping lines (inside a false conditional).

Source
sourcemap

Whether source map is enabled.

Source
sourcemap=(sourcemap : Bool)

Whether source map is enabled.

Source