Post processing of generated HTML

Hi there!
(noob here, so this q may be really dumb)

I’ve got a function that generates some HTML to assist the developers
(very similar to the form_tag ones):
def lozenge_bar ( black=false, blue=false, id="", &block )
content = capture( &block )
concat( tag(:div, {:class => “lozenge bar #{black||blue}”, :id => id},
true ), block.binding )
concat( content, block.binding )
concat( “”, block.binding )
end

I need to extend it so it processes the html assigned to “content”.
As an example, I need it to get the first and last div in “content” and
alter it a little.
Are there any helpers built into RoR that can assist me in this?

I’ve had a look at HTML::Selector, but I can never seem to get it to
work (I keep on getting “uninitialized constant HTML::Selector”), not
sure if its going to do what I need it to do anyway…

Thanks!