class Minidown::ListElement
Constants
- CheckedBox
- UnCheckedBox
Attributes
checked[RW]
contents[RW]
p_tag_content[RW]
task_list[RW]
Public Class Methods
new(*_)
click to toggle source
Calls superclass method
Minidown::Element::new
# File lib/minidown/elements/list_element.rb, line 7 def initialize *_ super @p_tag_content = false @contents = [TextElement.new(doc, content)] @task_list = false @checked = false end
Public Instance Methods
list_content()
click to toggle source
# File lib/minidown/elements/list_element.rb, line 28 def list_content content = @contents.map(&:to_html).join(@p_tag_content ? br_tag : "\n".freeze) if @task_list content = (@checked ? CheckedBox : UnCheckedBox) + content end content end
to_html()
click to toggle source
# File lib/minidown/elements/list_element.rb, line 15 def to_html @contents.map! do |content| ParagraphElement === content ? content.text : content end if @p_tag_content content = list_content content = build_tag('p'.freeze){|p| p << content} if @p_tag_content attr = nil attr = {class: 'task-list-item'.freeze} if @task_list build_tag 'li'.freeze, attr do |li| li << content end end