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



13
14
15
16
17
18
19
20
# File 'lib/rspec_documentation/kramdown_html_converter.rb', line 13

def convert_header(element, indent)
  [
    '<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
# File 'lib/rspec_documentation/kramdown_html_converter.rb', line 8

def convert_table(element, indent)
  element.attr['class'] ||= 'rspec-documentation-table table'
  super
end


22
23
24
# File 'lib/rspec_documentation/kramdown_html_converter.rb', line 22

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