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



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

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
  renderer_attr     = attrs["renderer"]
  strategy          = resolve_strategy(renderer_attr, backend)
  palette           = attrs.fetch("palette", "rainbow")
  pdf               = backend == "pdf"
  options           = Renderer::RenderOptions.new(
    width:          attrs.fetch("width", "100%"),
    height:         attrs["height"],
    palette:        palette,
    pdf:            pdf,
    name_converter: method(:identity)
  )
  case strategy
  when :html then render_html(parent, root, options)
  when :svg  then render_svg(parent, root, backend, options, attrs)
  end
end