Class: AsciidoctorDiagramLayout::Asciidoc::LayoutBlockProcessor

Inherits:
Asciidoctor::Extensions::BlockProcessor
  • Object
show all
Defined in:
lib/asciidoctor_diagram_layout/asciidoc/layout_block_processor.rb

Instance Method Summary collapse

Instance Method Details

#process(parent, reader, attrs) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/asciidoctor_diagram_layout/asciidoc/layout_block_processor.rb', line 12

def process(parent, reader, attrs)
  dsl           = reader.read
  implicit_dir  = attrs["direction"] == "cols" ? :cols : :rows
  root          = Parser.new.parse(dsl, implicit_dir)
  backend       = parent.document.attr("backend").to_s
  strategy      = resolve_strategy(attrs["renderer"], backend)
  palette       = attrs.fetch("palette", "rainbow")
  pdf           = backend == "pdf"
  title         = attrs["title"]
  options       = Renderer::RenderOptions.new(
    width:          attrs.fetch("width", "100%"),
    height:         attrs["height"],
    title:          title,
    palette:        palette,
    pdf:            pdf,
    name_converter: ->(name) { convert_inline(parent, name) }
  )
  case strategy
  when :html then render_html(parent, root, options)
  when :svg  then render_svg(parent, root, backend, options, attrs, title)
  end
end