Class: Kramdown::Converter::HtmlRspecDocumentation

Inherits:
Converter::Html
  • Object
show all
Defined in:
lib/rspec_documentation/kramdown_html_converter.rb

Overview

Custom HTML converter for kramdown. Invoked with ‘Kramdown::Document#to_html_rspec_documentation`. Applies a custom CSS class to Markdown tables when rendered to HTML.

Instance Method Summary collapse

Instance Method Details

#convert_header(element, indent) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/rspec_documentation/kramdown_html_converter.rb', line 15

def convert_header(element, indent)
  if rspec_documentation_example?
    element.attr['class'] = "no_toc #{element.attr['class']}"
    return super
  end

  [
    '<div class="heading">',
    super,
    "<a class='heading-anchor' href='##{element.attr['id']}'>#{link_icon}</a>",
    '</div>'
  ].join
end

#convert_table(element, indent) ⇒ Object



8
9
10
11
12
13
# File 'lib/rspec_documentation/kramdown_html_converter.rb', line 8

def convert_table(element, indent)
  return super if rspec_documentation_example?

  element.attr['class'] ||= 'rspec-documentation-table table'
  super
end


29
30
31
# File 'lib/rspec_documentation/kramdown_html_converter.rb', line 29

def link_icon
  @link_icon ||= RSpecDocumentation.template(:link, :svg).result
end