class Hpricot::Elements
def wrap(str = nil, &blk)
wrap(%{
})
doc.search("a[@href]").
deepest spot inside the first element.
If more than one element is found in the string, Hpricot locates the
Wraps each element in the list inside the element created by HTML +str+.
def wrap(str = nil, &blk) each do |x| wrap = x.make(str, &blk) nest = wrap.detect { |w| w.respond_to? :children } unless nest raise "No wrapping element found." end x.parent.replace_child(x, wrap) nest = nest.children.first until nest.empty? nest.html([x]) end end