class Mato::HtmlFilters::SectionAnchor

Constants

HX_PATTERN

Public Class Methods

new(anchor_icon_element = AnchorBuilder::DEFAULT_ANCHOR_ICON_ELEMENT) click to toggle source
# File lib/mato/html_filters/section_anchor.rb, line 11
def initialize(anchor_icon_element = AnchorBuilder::DEFAULT_ANCHOR_ICON_ELEMENT)
  @anchor_icon_element = anchor_icon_element
end

Public Instance Methods

call(doc) click to toggle source

@param [Nokogiri::HTML4::DocumentFragment] doc

# File lib/mato/html_filters/section_anchor.rb, line 16
def call(doc)
  anchor_builder = AnchorBuilder.new(@anchor_icon_element)

  doc.css(HX_PATTERN).each do |hx|
    hx.children = anchor_builder.make_anchor_element(hx) + hx.children.to_html
  end
end