Class: Methan::MdRenderer

Inherits:
Redcarpet::Render::HTML
  • Object
show all
Defined in:
lib/methan/md_renderer.rb

Instance Method Summary collapse

Instance Method Details

#list_item(text, list_type) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/methan/md_renderer.rb', line 8

def list_item(text, list_type)
  tag = "<li"
  r = /^\[(\s|x)\]\s/
  m = r.match(text)
  if m
    input_tag = "<input type=\"checkbox\""
    input_tag << " checked=\"true\"" if m[1] and m[1] == 'x'
    input_tag << ">"
    text = text.gsub(r, '')
    text = "#{input_tag} #{text}"
    tag << " class=\"task-item\""
  end
  tag << ">#{text}</li>"
  return tag
end