class Qiita::Markdown::Filters::Toc::Heading

Public Class Methods

new(node) click to toggle source
# File lib/qiita/markdown/filters/toc.rb, line 13
def initialize(node)
  @node = node
  @id = node.attr("id")
  raise unless @id
end

Public Instance Methods

anchor_element() click to toggle source
# File lib/qiita/markdown/filters/toc.rb, line 28
def anchor_element
  %(<span id="#{@id}" class="fragment"></span><a href="##{@id}"><i class="fa fa-link"></i></a>)
end
decorate() click to toggle source
# File lib/qiita/markdown/filters/toc.rb, line 19
def decorate
  remove_heading_id
  first_child.add_previous_sibling(anchor_element) if first_child
end
first_child() click to toggle source
# File lib/qiita/markdown/filters/toc.rb, line 32
def first_child
  @first_child ||= @node.children.first
end
remove_heading_id() click to toggle source
# File lib/qiita/markdown/filters/toc.rb, line 24
def remove_heading_id
  @node.remove_attribute("id")
end