Class: Asciidoctor::Html::SubnavBlockMacro

Inherits:
Extensions::BlockMacroProcessor
  • Object
show all
Defined in:
lib/asciidoctor/html/subnav_block_macro.rb

Overview

Inserts a subnav for a chapter

Instance Method Summary collapse

Instance Method Details

#process(parent, target, attrs) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/asciidoctor/html/subnav_block_macro.rb', line 15

def process(parent, target, attrs)
  doc_key = Pathname(target).sub_ext "" unless target.empty?
  title = %(<h5 class="block-title">#{parent.apply_subs attrs["title"]}</h5>) if attrs.include?("title")
  bordered_class = " bordered" if attrs.include?("border")
  border_width = attrs["border"].to_i if bordered_class
  style = %( style="border-top-width: #{border_width}px; border-bottom-width: #{border_width}px;") if border_width
  roles = " #{attrs["role"]}" if attrs.include?("role")
  content = <<~HTML
    <div class="subnav#{bordered_class}#{roles}"#{style}>
      #{title}
      <nav>
      <%= templates.dig("#{doc_key}", "outline") || outline %>
      </nav>
    </div>
  HTML
  create_pass_block parent, content, attrs, subs: nil
end