Module: MdocsKramdown::Converter::MdocsHtml

Defined in:
lib/mdocs_kramdown/converter/mdocs_html.rb

Instance Method Summary collapse

Instance Method Details

#convert_blockquote(el, indent) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/mdocs_kramdown/converter/mdocs_html.rb', line 8

def convert_blockquote(el, indent)
  return super unless el.options[:admonition]

  classes = el.attr[:types]
  title = el.attr[:title]
  
  if el.options[:collapsible]
    element_id = Digest::MD5.hexdigest el.inspect
    
    format_as_indented_block_html('div', { class: "card #{classes.join(' ')} collapsible" },
      (title ? format_as_indented_block_html('div', { class: 'card-header collapsed', 'data-bs-toggle'=>'collapse','data-bs-target'=>"#collapse-#{element_id}"}, title.strip, indent + 2) : '') +
      format_as_indented_block_html('div', { class: 'collapse', id: "collapse-#{element_id}" },
        format_as_indented_block_html('div', { class: 'card-body' },
          format_as_indented_block_html('div', { class: 'card-text' }, inner(el, indent + 2), indent + 2),
        indent + 1),
      indent + 1),
    indent)

  else
    format_as_indented_block_html('div', { class: "card #{classes.join(' ')}" },
                                  (title ? format_as_indented_block_html('div', { class: 'card-header' }, title.strip, indent + 2) : '') +
                                  format_as_indented_block_html('div', { class: 'card-body' },
                                                                format_as_indented_block_html('div', { class: 'card-text' }, inner(el, indent + 2), indent + 2),
                                                                indent + 1),
                                  indent)
  end
end

#convert_table(el, indent) ⇒ Object



36
37
38
39
# File 'lib/mdocs_kramdown/converter/mdocs_html.rb', line 36

def convert_table(el, indent)
  el.attr[:class] = 'table'
  super
end

#initialize(root, options) ⇒ Object



4
5
6
# File 'lib/mdocs_kramdown/converter/mdocs_html.rb', line 4

def initialize(root, options)
  super(root, options)
end