depth_first

in _plugins/html_filters.rb [39:65]


    def depth_first(root, &block)
      parent = root.parent
      sibling = root.next
      first_child = root.children.first
  
      yield(root)
  
      if first_child
        depth_first(first_child, &block)
      else
        if sibling
          depth_first(sibling, &block)
        else
          
          n = parent
          while n && n.next.nil? && n.name != "document"
            n = n.parent
          end

          
          if n && n.next
            depth_first(n.next, &block)
          end
        end
      end  
    end