Class: Bhook::Converter::Html

Inherits:
Kramdown::Converter::Html
  • Object
show all
Extended by:
T::Sig
Defined in:
lib/bhook/converter/html.rb

Instance Method Summary collapse

Constructor Details

#initialize(root, options) ⇒ Html

Returns a new instance of Html.



10
11
12
13
# File 'lib/bhook/converter/html.rb', line 10

def initialize(root, options)
  @options = T.let({}, T::Hash[Symbol, T.untyped])
  super(root, options)
end

Instance Method Details

#convert_a(el, indent) ⇒ Object



16
17
18
19
20
21
22
23
# File 'lib/bhook/converter/html.rb', line 16

def convert_a(el, indent)
  href_path = el.attr['href']
  if valid_relative_md_link?(href_path)
    L.debug "Found link: #{href_path}"
    el.attr['href'].gsub!(/\.md/, '.html')
  end
  super(el, indent)
end

#convert_header(el, indent) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/bhook/converter/html.rb', line 26

def convert_header(el, indent)
  src_title = el.options[:raw_text]
  after_h1_html = @options[:after_h1_strategy].call(binding)

  level = output_header_level(el.options[:level])
  if level == 1
    @options[:h1_callback].call(src_title)
    "#{super(el, indent)}#{' ' * indent}#{after_h1_html}"
  else
    insert_anchor_into_header!(el)
    super(el, indent)
  end
end