Class: Asciidoctor::Ptc::BlockMacroProcessor

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

Overview

Block macro reading from a file:

ptc::path/to/study.ptc[format=png,view=Residual]

Instance Method Summary collapse

Methods included from Processor

#render_ptc

Instance Method Details

#process(parent, target, attrs) ⇒ Object



167
168
169
170
171
172
173
174
175
176
177
# File 'lib/asciidoctor/ptc/extension.rb', line 167

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 .ptc file: #{target}")
  end

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