Class | Asciidoctor::PreprocessorReader |
In: |
lib/asciidoctor/reader.rb
|
Parent: | Reader |
Public: Methods for retrieving lines from AsciiDoc source files, evaluating preprocessor directives as each line is read off the Array of lines.
include_stack | [R] | |
includes | [R] |
Public: 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.
Returns the next line of the source data as a String if there are lines remaining in the current include context or a parent include context. Returns nothing if there are no more lines remaining and the include stack is empty.
Internal: Preprocess the directive to conditionally include or exclude content.
Preprocess the conditional directive (ifdef, ifndef, ifeval, endif) under the cursor. If Reader is currently skipping content, then simply track the open and close delimiters of any nested conditional blocks. If Reader is not skipping, mark whether the condition is satisfied and continue preprocessing recursively until the next line of available content is found.
keyword - The conditional inclusion directive (ifdef, ifndef, ifeval, endif) target - The target, which is the name of one or more attributes that are
used in the condition (blank in the case of the ifeval directive)
delimiter - The conditional delimiter for multiple attributes (’+’ means all
attributes must be defined or undefined, ',' means any of the attributes can be defined or undefined.
text - The text associated with this directive (occurring between the square brackets)
Used for a single-line conditional block in the case of the ifdef or ifndef directives, and for the conditional expression for the ifeval directive.
Returns a Boolean indicating whether the cursor should be advanced
Internal: Preprocess the directive to include lines from another document.
Preprocess the directive to include the target document. The scenarios are as follows:
If SafeMode is SECURE or greater, the directive is ignore and the include directive line is emitted verbatim.
Otherwise, if an include processor is specified pass the target and attributes to that processor and expect an Array of String lines in return.
Otherwise, if the max depth is greater than 0, and is not exceeded by the stack size, normalize the target path and read the lines onto the beginning of the Array of source data.
If none of the above apply, emit the include directive line verbatim.
target - The name of the source document to include as specified in the
target slot of the include::[] directive
Returns a Boolean indicating whether the line under the cursor has changed.
Public: Push source onto the front of the reader and switch the context based on the file, document-relative path and line information given.
This method is typically used in an IncludeProcessor to add source read from the target specified.
Examples
path = 'partial.adoc' file = File.expand_path path data = IO.read file reader.push_include data, file, path
Returns this Reader object.
Private: Resolve the value of one side of the expression
Examples
expr = '"value"' resolve_expr_val expr # => "value" expr = '"value' resolve_expr_val expr # => "\"value" expr = '"{undefined}"' resolve_expr_val expr # => "" expr = '{undefined}' resolve_expr_val expr # => nil expr = '2' resolve_expr_val expr # => 2 @document.attributes['name'] = 'value' expr = '"{name}"' resolve_expr_val expr # => "value"
Returns The value of the expression, coerced to the appropriate type
TODO Document this override also, we now have the field in the super class, so perhaps just implement the logic there?