class Asciidoctor::PreprocessorReader
def resolve_include_path target, attrlist, attributes
Returns An Array containing the resolved (absolute) include path, the target type, and the path
attributes - A Hash of attributes parsed from attrlist.
attrlist - An attribute list String (i.e., the text between the square brackets).
(Attribute references in target value have already been resolved).
target - A String containing the unresolved include target.
environment.
This method is overridden in Asciidoctor.js to resolve the target of an include in the browser
cursor should be advanced beyond this line (true) or the line should be reprocessed (false).
return a boolean to halt processing of the include directive line and to indicate whether the
and the path of the target relative to the outermost document. Alternately, the method may
Array containing the resolved (absolute) path of the target, the target type (:file or :uri),
An internal method to resolve the target of an include directive. This method must return an
Internal: Resolve the target of an include directive.
def resolve_include_path target, attrlist, attributes doc = @document if (Helpers.uriish? target) || (::String === @dir ? nil : (target = %(#{@dir}/#{target}))) unless doc.attr? 'allow-uri-read' target = %(pass:c[#{target}]) if target.include? ' ' return replace_next_line %(link:#{target}[role=include]) end if doc.attr? 'cache-uri' # caching requires the open-uri-cached gem to be installed # processing will be automatically aborted if these libraries can't be opened Helpers.require_library 'open-uri/cached', 'open-uri-cached' unless defined? ::OpenURI::Cache elsif !RUBY_ENGINE_OPAL # autoload open-uri ::OpenURI end [(::URI.parse target), :uri, target] else # include file is resolved relative to dir of current include, or base_dir if within original docfile inc_path = doc.normalize_system_path target, @dir, nil, target_name: 'include file' unless ::File.file? inc_path if attributes['optional-option'] logger.info { message_with_context %(optional include dropped because include file not found: #{inc_path}), source_location: cursor } shift return true else logger.error message_with_context %(include file not found: #{inc_path}), source_location: cursor return replace_next_line %(Unresolved directive in #{@path} - include::#{target}[#{attrlist}]) end end # NOTE relpath is the path relative to the root document (or base_dir, if set) # QUESTION should we move relative_path method to Document relpath = doc.path_resolver.relative_path inc_path, doc.base_dir [inc_path, :file, relpath] end end