Class: Asciidoctor::Ldl::BlockMacroProcessor

Inherits:
Extensions::BlockMacroProcessor
  • Object
show all
Includes:
Processor
Defined in:
lib/asciidoctor/ldl/extension.rb

Overview

Block macro reading from a file:

ldl::path/to/diagram.ldl[format=png, scale=2]

Instance Method Summary collapse

Methods included from Processor

#render_ldl

Instance Method Details

#process(parent, target, attrs) ⇒ Object



143
144
145
146
147
148
149
150
151
152
153
# File 'lib/asciidoctor/ldl/extension.rb', line 143

def process(parent, target, attrs)
  doc = parent.document
  path = doc.normalize_system_path(target, doc.attr('docdir'))
  unless File.readable?(path)
    return error_block(parent, attrs, "cannot read LDL file: #{target}")
  end

  source = File.read(path)
  hint = attrs['target'] || File.basename(target, File.extname(target))
  render_ldl(parent, source, attrs, hint)
end