Class: MarkdownUI::Header

Inherits:
Object
  • Object
show all
Defined in:
lib/markdown-ui/header/header.rb

Instance Method Summary collapse

Constructor Details

#initialize(text, level) ⇒ Header

Returns a new instance of Header.



3
4
5
6
# File 'lib/markdown-ui/header/header.rb', line 3

def initialize(text, level)
  @text, @klass = text.split(":")
  @level = level
end

Instance Method Details

#renderObject



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/markdown-ui/header/header.rb', line 8

def render
  text = @text.strip
  klass = MarkdownUI::KlassUtil.new("ui #{@klass} header").klass
  level = @level

  output = []

  if @level > 0
    output << "<h#{@level}"
    output << klass + ">"
    output << "#{@text}"
    output << "</h#{level}>"
  else
    output << "<div"
    output << klass + ">"
    output << "#{@text}"
    output << "</div>"
  end

  output.join
end