module Asciidoctor
def self.load(input, options = {}, &block)
block - a callback block for handling include::[] directives
see Asciidoctor::Document#initialize for details
options - a Hash of options to control processing (default: {})
input - the AsciiDoc source as a IO, String or Array.
Document object.
input is a File, information about the file is stored in attributes on the
Accepts input as an IO (or StringIO), String or String Array object. If the
Public: Parse the AsciiDoc source input into an Asciidoctor::Document
def self.load(input, options = {}, &block) lines = nil if input.is_a?(File) options[:attributes] ||= {} attrs = options[:attributes] lines = input.readlines input_mtime = input.mtime input_path = File.expand_path(input.path) # hold off on setting infile and indir until we get a better sense of their purpose attrs['docfile'] = input_path attrs['docdir'] = File.dirname(input_path) attrs['docname'] = File.basename(input_path, File.extname(input_path)) attrs['docdate'] = input_mtime.strftime('%Y-%m-%d') attrs['doctime'] = input_mtime.strftime('%H:%M:%S %Z') attrs['docdatetime'] = [attrs['docdate'], attrs['doctime']] * ' ' elsif input.respond_to?(:readlines) input.rewind rescue nil lines = input.readlines elsif input.is_a?(String) lines = input.lines.entries elsif input.is_a?(Array) lines = input.dup else raise "Unsupported input type: #{input.class}" end Document.new(lines, options, &block) end