Class: Qiita::Markdown::Filters::Checkbox::List

Inherits:
Object
  • Object
show all
Includes:
Mem
Defined in:
lib/qiita/markdown/filters/checkbox.rb

Constant Summary collapse

CHECKBOX_CLOSE_MARK =
"[x] "
CHECKBOX_OPEN_MARK =
"[ ] "

Instance Method Summary collapse

Constructor Details

#initialize(node) ⇒ List

Returns a new instance of List.



25
26
27
# File 'lib/qiita/markdown/filters/checkbox.rb', line 25

def initialize(node)
  @node = node
end

Instance Method Details

#convertObject



33
34
35
36
37
# File 'lib/qiita/markdown/filters/checkbox.rb', line 33

def convert
  first_text_node.content = first_text_node.content.sub(checkbox_mark, "").lstrip
  first_text_node.add_previous_sibling(checkbox_node)
  @node["class"] = "task-list-item"
end

#has_checkbox?Boolean

Returns:

  • (Boolean)


29
30
31
# File 'lib/qiita/markdown/filters/checkbox.rb', line 29

def has_checkbox?
  has_open_checkbox? || has_close_checkbox?
end