Class: ExtraExtra::SemanticHtmlRenderer

Inherits:
Redcarpet::Render::HTML
  • Object
show all
Defined in:
lib/extra_extra/semantic_html_renderer.rb

Instance Method Summary collapse

Constructor Details

#initialize(opts = {}) ⇒ SemanticHtmlRenderer

Returns a new instance of SemanticHtmlRenderer.


4
5
6
7
8
9
# File 'lib/extra_extra/semantic_html_renderer.rb', line 4

def initialize(opts={})
  @header_level_offset = opts.delete(:header_level_offset) || 1
  @header_class_prefix = opts.delete(:header_class_prefix) || "h"
  @header_class_prefix_offset = opts.delete(:header_class_prefix_offset) || (@header_level_offset + 1)
  super(opts)
end

Instance Method Details

#header(text, header_level, anchor = nil) ⇒ Object


10
11
12
13
# File 'lib/extra_extra/semantic_html_renderer.rb', line 10

def header(text, header_level,anchor=nil)
  anchor ||= text.parameterize
  "<a name='#{anchor}'></a><h#{header_level+@header_level_offset} class='#{@header_class_prefix}#{header_level+@header_class_prefix_offset}'>#{text}</h#{header_level+@header_level_offset}>"
end