Class: Jekyll::FastReader::HtmlWalker

Inherits:
Object
  • Object
show all
Defined in:
lib/jekyll/fast_reader/html_walker.rb

Instance Method Summary collapse

Constructor Details

#initialize(exclude_selectors) ⇒ HtmlWalker

Returns a new instance of HtmlWalker.



4
5
6
# File 'lib/jekyll/fast_reader/html_walker.rb', line 4

def initialize(exclude_selectors)
  @exclude_selectors = exclude_selectors
end

Instance Method Details

#walk(root, &block) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
# File 'lib/jekyll/fast_reader/html_walker.rb', line 8

def walk(root, &block)
  return if element_excluded?(root)

  root.children.each do |node|
    if node.text?
      block.call(node) unless trails_anchor?(node)
    elsif node.element?
      walk(node, &block)
    end
  end
end