I need to strip out all font tags from a document. When attempting to do so with the following Ruby code, other elements and text within the font tags are lost. I've also attempted to iterate through all children elements and make them siblings of the font tag before unlinking the font tag--which also results in lost HTML. What is a good method for removing tags which can contain other elements and/or text?
doc.css('font').each do |element|
element.unlink
end
UPDATE (in response to first solution):
The problem with using node.children to obtain the children and then move the children to the font node's parent node is that none of the children nodes include the text found within the font node. As soon as the font tag is removed (unlinked), all text within the font tag also disappears from the document.
My revised question is thus: how do I use Nokogiri to obtain the text of the font node and how can this text be moved to replace the font tag, in the font node's position.